Skip to content

Instantly share code, notes, and snippets.

@jeffremer
Created November 9, 2011 02:19
Show Gist options
  • Save jeffremer/1350116 to your computer and use it in GitHub Desktop.
Save jeffremer/1350116 to your computer and use it in GitHub Desktop.
Capture View
- (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