Is it possible in objective C that we can take the screen shot of screen and stored this image in UIImage.
- (void)SnapShot {
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, [UIScreen mainScreen].scale);
} else {
UIGraphicsBeginImageContext(self.view.bounds.size);
}
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *data = UIImagePNGRepresentation(image);
[data writeToFile:@"snapshot.png" options:NSDataWritingWithoutOverwriting error:Nil];
[data writeToFile:@"snapshot.png" atomically:YES];
UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
}