Last active
August 29, 2015 14:26
-
-
Save KentarouKanno/36dee31444ac2a332b60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UIViewをUIImageに変換する(objective-c) | |
- (UIImage*)convertUIimageFromUIview:(UIView*)view { | |
UIGraphicsBeginImageContext(view.frame.size); | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} | |
// UIViewをUIImageに変換する(Swift) | |
func convertUIimageFromUIview(view: UIView) -> UIImage { | |
UIGraphicsBeginImageContext(view.frame.size) | |
view.layer .renderInContext(UIGraphicsGetCurrentContext()) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment