图片渐渐淡入淡出

最近要做个需求 , 要把图片渐渐的显示效果

引入头文件 , 做个分类搞定

代码如下 :

#import"UIImageView+WebCache.h"


+ (void)loadImgWithPlaceholder:(UIImage *)placeImg url:(NSString *)urlStr imgView:(UIImageView *)imgView

{

[imgView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:placeImg completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

if(error && !image)

{

return;

}

else

{

if(cacheType == SDImageCacheTypeNone)

{

//下载的

[UIView transitionWithView:imgView duration:0.5foptions:UIViewAnimationOptionTransitionCrossDissolve animations:^{

imgView.image = image;

} completion:NULL];

}

else

{

//内存缓存中的

imgView.image = image;

}

}

}];

}

你可能感兴趣的:(图片渐渐淡入淡出)