创建UIImageView对象
UIImageView *gtp = [[UIImageView alloc] init];
ZGLPhotoModel *model = _modelArr[_currentPage];
**重点内容**
[gtp setImageWithURL:[NSURL URLWithString:model.raw_url]];
UIImageWriteToSavedPhotosAlbum(gtp.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
/* 下载图片方法 */
方法实现
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
NSString *msg = nil ;
if(error != NULL){
msg = @"保存图片失败" ;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancel =[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:^{
}];
}
}