Created
December 21, 2011 01:10
-
-
Save Arclite/1504080 to your computer and use it in GitHub Desktop.
Screenshot a view in iOS
This file contains 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
UIGraphicsBeginImageContext([myView bounds].size); | |
UIGraphicsPushContext(UIGraphicsGetCurrentContext()); | |
[[myView layer] renderInContext:UIGraphicsGetCurrentContext()]; | |
UIGraphicsPopContext(); | |
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext(); | |
NSLog(@"screenshot data: %@", UIImagePNGRepresentation(screenshot)); //dumps a bunch of hex, use Hex Fiend to view it. | |
UIGraphicsEndImageContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment