CODE 1
import "QuartzCore.framework"
// .h file
-(IBAction)captureScreen:(id)sender;
// .m file
#import <QuartzCore/QuartzCore.h>
-(IBAction)captureScreen:(id)sender
{
UIGraphicsBeginImageContext(self.view.window.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
}
//Code 2
CGImageRef UIGetScreenImage(void);
CGImageRef originalImage = UIGetScreenImage();
CGImageRef videoImage = CGImageCreateWithImageInRect(originalImage,CGRectMake(0,66,320,230));UIImage *snapShotImage = [UIImage imageWithCGImage:videoImage];
UIImageWriteToSavedPhotosAlbum(snapShotImage, nil, nil, nil);
CGImageRelease(originalImage);
CGImageRelease(videoImage);
Comments
Post a Comment