iOS 保存图片或者视图到本地相册

来源:互联网 发布:为什么28岁不能学java 编辑:程序博客网 时间:2024/05/17 10:38

//保存视图

pragma mark - 保存视图

UIGraphicsBeginImageContext(self.qrView.bounds.size);[self.qrView.layer renderInContext:UIGraphicsGetCurrentContext()];UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();UIImageWriteToSavedPhotosAlbum(viewImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);

pragma mark - 保存图片

UIImage *image;UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);

//结果
- (void)image:(UIImage )image didFinishSavingWithError:(NSError )error contextInfo:(void *)contextInfo{
if (error) {
NSLog(@”失败”);
}else{
NSLog(@”成功”);
}
}

1 0
原创粉丝点击