/**
* 简单截屏并将图片保存到本地
*/
-(void)makeScreenShotCompletion:(void(^)(UIImage * image))completion{
//开启上下文 <span style="font-family: Arial, Helvetica, sans-serif;">设置截屏大小</span>
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
//获取图片
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
completion(image);
/**
* 将图片保存到本地相册
*/
UIImageWriteToSavedPhotosAlbum(image, self , @selector(image:didFinishSavingWithError:contextInfo:), nil);//保存图片到照片库
}
/**
* 图片保存到本地后的回调
*/
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo{
if(!error){
NSLog(@"保存成功");
}
}