Created
August 21, 2013 13:19
-
-
Save aspitz/6294359 to your computer and use it in GitHub Desktop.
Category code to capture a UIView as a UIImage
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
#import "UIImage+UIViewCapture.h" | |
#import <QuartzCore/QuartzCore.h> | |
@implementation UIImage (UIViewCapture) | |
+ (UIImage *)imageWithView:(UIView *)view{ | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0); | |
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return img; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment