//截图
-(UIImage *)captureCurrentView :(UIView *)view{
CGRect frame = view.frame;
UIGraphicsBeginImageContext(frame.size);
CGContextRef contextRef =UIGraphicsGetCurrentContext();
[view.layerrenderInContext:contextRef];
UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImage *saveImage = [UIImageimageWithCGImage:CGImageCreateWithImageInRect(image.CGImage,CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height))];
return saveImage;
}
//保存图片
-(void)saveImageToPhotos:(UIImage *)image{
UIImageWriteToSavedPhotosAlbum(image, self,@selector(image:didFinishSavingWithError:contextInfo:),NULL);
}
//保存回调
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSString *msg = nil ;
if(error != NULL){
msg =@"保存图片失败" ;
}else{
msg = @"保存图片成功" ;
}
}