Skip to content

Instantly share code, notes, and snippets.

@mbeaty
Created January 27, 2012 05:42
Show Gist options
  • Save mbeaty/1687232 to your computer and use it in GitHub Desktop.
Save mbeaty/1687232 to your computer and use it in GitHub Desktop.
iPhone Screenshot in code
// Capture Screenshot - Need to verify this still works in iOS 5
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data = UIImageJPEGRepresentation(screenshotImage,self.jpegCompressionRate);
NSUInteger len = [data length];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment