UIImageJPEGRepresentation 問題

weixin_34308389發表於2018-07-18

UIImageJPEGRepresentation會導致透明底變為白底
UIImagePNGRepresentation替換
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:item.iconUrl]];
[imageView setImageWithURLRequest:request placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
NSData *data = UIImagePNGRepresentation(image);
[FileManager saveCacheImgWith:data imgName:[NSString stringWithFormat:@"%ld",(long)item.itemId] path:[FileManager getDeviceIconExaplePath] fileExtension:@"png"];

            NSLog(@"下載成功 %@", item.itemName);
        } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
            NSLog(@"下載失敗 %@", item.itemName);
        }];