iOS截取指定区域的图
2019-03-25 本文已影响0人
super_2e20
info 加相册权限
UIImage *iamge =[self screenShotView:self.scrollView];
UIImageWriteToSavedPhotosAlbum(iamge, self, @selector(image:didFinishSavingWithError:contextInfo:), (__bridge void *)self);
- (UIImage )screenShotView:(UIView)view{
UIImage *image = [[UIImage alloc]init];
CGSize size;
size.width = SCREEN_WIDTH;
size.height = FIT(170);
UIGraphicsBeginImageContextWithOptions(size, false, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
pragma mark -- <保存到相册>
-(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
NSString *msg = nil ;
if(error){
msg = @"保存图片失败" ;
}else{
msg = @"保存图片成功" ;
}
}