Skip to content

Instantly share code, notes, and snippets.

@remirobert
Created April 2, 2015 15:01
Show Gist options
  • Save remirobert/236778b711b352c17b51 to your computer and use it in GitHub Desktop.
Save remirobert/236778b711b352c17b51 to your computer and use it in GitHub Desktop.
create a screenshot
+ (UIImage*)getScreenShot:(UIView*)view {
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[view.layer renderInContext:ctx];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return screenImage;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment