Here is a quick post, in which I am posting a quick snippet to capture the current screen of iPhone and save it to the phone library. This piece of code will be helpful in generating screen-shot of any iPhone application programmatically.
-
–(void)saveScreen
-
{
-
CGRect myRect = [self.view bounds];
-
UIGraphicsBeginImageContext(myRect.size);
-
CGContextRef ctx = UIGraphicsGetCurrentContext();
-
[[UIColor blackColor] set];
-
CGContextFillRect(ctx, myRect);
-
[self.view.layer renderInContext:ctx];
-
UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();
-
UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil);
-
UIGraphicsEndImageContext();
-
}
Please leave your comments here so that I can find out, if you find this snippet useful or not
Enjoy!
Enjoyed reading this a lot