目前我的图片只是弹出进入视图。我希望它们能够淡出。
我试过这个,没有运气:
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache queryDiskCacheForKey:encodedString done:^(UIImage *image, SDImageCacheType cacheType) {
if (image){
cell.thumbnailImageView.image = image;
}else{
[cell.thumbnailImageView setImageWithURL:[NSURL URLWithString:encodedString] placeholderImage:myImage completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
[imageCache storeImage:image forKey:encodedString];
}];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.alpha = 0;
[UIView animateWithDuration:5.0 animations:^{
imageView.alpha = 1.0;
}];
}
}];
答案 0 :(得分:0)
你的else块应如下所示:
[[SDWebImageManager sharedManager] downloadWithURL:[NSURL URLWithString:encodedString]
options:0
progress:nil
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
[imageCache storeImage:image forKey:encodedString];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.alpha = 0;
[UIView animateWithDuration:5.0 animations:^{
imageView.alpha = 1.0;
}];
}];
答案 1 :(得分:0)
尝试以下代码。
__ weak typeof(UIImageView)* weakimgView = imgView;
[imgView setImageWithURL:[NSURL URLWithString:_photo.url placeholderImage:[UIImage imageNamed:@"photoIcon"] options:SDWebImageRetryFailed completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
[weakimgView setAlpha:0.4];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
weakimgView.image = image;
[weakimgView setAlpha:1.0];
[UIView commitAnimations];
}];
希望这会对你有所帮助。快乐编码:)