Created
November 9, 2011 02:19
-
-
Save jeffremer/1350116 to your computer and use it in GitHub Desktop.
Capture View
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 *)view | |
{ | |
CGRect screenRect = [[UIScreen mainScreen] bounds]; | |
UIGraphicsBeginImageContext(screenRect.size); | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
[[UIColor blackColor] set]; | |
CGContextFillRect(ctx, screenRect); | |
[view.layer renderInContext:ctx]; | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment