使用SDWebimage加载图片,添加渐进动画方式:
1.找到UIView+WebCache.m
2.143行 if(iage){ 【用如下代码替换】} 括号内用如下代码替换
CATransition *animation = [CATransition animation];
animation.duration = .85f;
animation.type = kCATransitionFade;
animation.removedOnCompletion = YES;
[self.layer addAnimation:animation forKey:@"transition"];
targetImage= image;
targetData = data;
[self setNeedsLayout];
3.在 [self sd_setImageLoadOperation:operation forKey:validOperationKey] 方法上面添加[self.layer removeAnimationForKey:@"transition"];用以移除添加的渐进动画
效果如下:
SDWebimage 加载图片渐变