Created
December 21, 2012 15:57
-
-
Save fantattitude/4353648 to your computer and use it in GitHub Desktop.
UIView to UIImage category method by @Dimillian
This file contains 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
+ (UIImage*)captureView:(UIView *)viewToCapture { | |
if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) | |
UIGraphicsBeginImageContextWithOptions(viewToCapture.bounds.size, NO, [UIScreen mainScreen].scale); | |
else | |
UIGraphicsBeginImageContext(viewToCapture.bounds.size); | |
[viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment