.m File
-(void)Generate_Image
{
UIGraphicsBeginImageContext(self.Scrollview.contentSize);
{
CGPoint savedContentOffset = self.Scrollview.contentOffset;
CGRect savedFrame = self.Scrollview.frame;
self.Scrollview.contentOffset = CGPointZero;
[self.Scrollview.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
self.Scrollview.contentOffset = savedContentOffset;
self.Scrollview.frame = savedFrame;
}
UIGraphicsEndImageContext();
//Save Image to Local Library
UIImageWriteToSavedPhotosAlbum(image, 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