Skip to content

Instantly share code, notes, and snippets.

@guruguruman
Created May 11, 2013 08:32
Show Gist options
  • Save guruguruman/5559318 to your computer and use it in GitHub Desktop.
Save guruguruman/5559318 to your computer and use it in GitHub Desktop.
Capturing image from rendered view.
+ (UIImage *)viewAsImage:(UIView *)aView {
if (!aView) {
return nil;
}
UIGraphicsBeginImageContext(aView.bounds.size);
[aView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *aViewAsImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return aViewAsImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment