UIImageView *gtp = [[UIImageView alloc] init];
? ? [gtp sd_setImageWithURL:[NSURL URLWithString:@"https://wx1.sinaimg.cn/mw690/00632esply1fnloc9x8fgj31kw16ou0y.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"]];
? ? [gtp sd_setImageWithPreviousCachedImageWithURL:[NSURL URLWithString:@"https://wx1.sinaimg.cn/mw690/00632esply1fnloc9x8fgj31kw16ou0y.jpg"] placeholderImage:[UIImage imageNamed:@"placeholder"] options:SDWebImageCacheMemoryOnly progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
? ? ? ? NSLog(@"已接收%f,總大小%ld",(CGFloat)receivedSize,(long)expectedSize);
? ? } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
? ? ? ? //url加載完 在保存圖片
? ? ? ? UIImageWriteToSavedPhotosAlbum(gtp.image, self, @selector(savedPhotoImage:didFinishSavingWithError:contextInfo:), nil);
? ? }];
//保存完成后調(diào)用的方法
- (void)savedPhotoImage:(UIImage*)image didFinishSavingWithError: (NSError *)error contextInfo: (void *)contextInfo {
? ? if (error) {
? ? ? ? NSLog(@"保存圖片出錯%@", error.localizedDescription);
? ? }
? ? else {
? ? ? ? NSLog(@"保存圖片成功");
? ? }
}