Quote:
Originally Posted by justill45
yeah, i didnt see the second page of this thread, but yeah, pretty cool. Is there any place i can see how to use this method?
|
I think the following should work (untested):
In your AppDelegate.m or any other .m where you want to use this feature, add the following lines of code right below the #import section:
Code:
CGImageRef UIGetScreenImage();
@interface UIImage (ScreenImage)
+ (UIImage *)imageWithScreenContents;
@end
@implementation UIImage (ScreenImage)
+ (UIImage *)imageWithScreenContents
{
CGImageRef cgScreen = UIGetScreenImage();
if (cgScreen) {
UIImage *result = [UIImage imageWithCGImage:cgScreen];
CGImageRelease(cgScreen);
return result;
}
return nil;
}
@end
Now you can grab the screen like that:
Code:
- (void)grabScreen {
CGImageRef screen = UIGetScreenImage();
UIImage *screenImage = [UIImage imageWithCGImage:screen];
//now save your image or do with it whatever you like
}