12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //
- // UIImageView+webImage.m
- // LampRibbon
- //
- // Created by coderYK on 2017/8/9.
- // Copyright © 2017年 RD-iOS. All rights reserved.
- //
- #import "UIImageView+webImage.h"
- @implementation UIImageView (webImage)
- - (void)rds_downloadImage:(NSString *)url placeHoler:(UIImage *)placeHoler {
-
- [self sd_setImageWithURL:[NSURL URLWithString:url]
- placeholderImage:placeHoler
- options:SDWebImageLowPriority | SDWebImageRetryFailed];
- }
- - (void)rds_downloadImage:(NSString *)url
- placeHoler:(UIImage *)placeHoler
- success:(rds_DownloadSuccessBlock)success
- failure:(rds_DownloadFailureBlock)failure
- received:(rds_DownloadProgressBlock)progress {
-
-
- [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeHoler options:SDWebImageRetryFailed | SDWebImageLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
-
- if (progress) {
- progress((float)receivedSize/expectedSize);
- }
-
- } completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
-
- if (error && failure) {
- failure(error);
- }
- else if(success){
-
- self.image = image;
- success(cacheType, image);
- }
- }];
-
-
- }
- @end
|