Screen Shot for View
Add the Framework : QuartzCore.framework
.h File:
#import <QuartzCore/QuartzCore.h>
#import <QuartzCore/QuartzCore.h>
.m File (Button for CaptureImage):
//Coding for Screen Shot for View(saved to Photo Library in Your Device)
UIGraphicsBeginImageContext(self.view.frame.size);
[[self.view layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//Save Image to Local Library
UIImageWriteToSavedPhotosAlbum(screenshot, self,@selector(image:didFinishSavingWithError:contextInfo:), nil);
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
if (error)
{
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
}
else
{
alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"Image saved to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
}
[alert show];
}
No comments:
Post a Comment