IPhone screen capture to view

On iphone, is it possible to "capture the screen" of a UIView and all its previews? If possible, how?

+6
ios objective-c cocoa-touch
source share
1 answer

I found this , but I have not tried it myself.

Here you will find the used -renderInContext .

I converted the code above to a category on a UIView. name it like this: [aView saveScreenshotToPhotosAlbum];

 #import <QuartzCore/QuartzCore.h> - (UIImage*)captureView { CGRect rect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } - (void)saveScreenshotToPhotosAlbum { UIImageWriteToSavedPhotosAlbum([self captureView], nil, nil, nil); } 
+9
source share

All Articles