Created
December 7, 2011 00:48
-
-
Save madson/1440850 to your computer and use it in GitHub Desktop.
Getting UIImage from UIView
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 rect = [view bounds]; | |
UIGraphicsBeginImageContext(rect.size); | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
[[UIColor blackColor] set]; | |
CGContextFillRect(ctx, rect); | |
[view.layer renderInContext:ctx]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment