UIImageView分类

#import <YYKit/YYKit.h>

#import <SDWebImage/UIImageView+WebCache.h>

@interface UIImageView (Extension)

// 没有占位图片

- (void)setHeaderUrl:(NSString *)url;

// 带有占位图片

- (void)setHeaderUrl:(NSString *)url withplaceholderImageName:(NSString *)placeholderImageName;

 

@end

 

#import "UIImageView+Extension.h"

#import "UIImage+Extension.h"

 

@implementation UIImageView (TVExtension)

- (void)setHeaderUrl:(NSString *)url

{

    [self setCircleHeaderUrl:url];

}

 

- (void)setCircleHeaderUrl:(NSString *)url

{

    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"img_studio_default"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

        if (image == nil) return;

        self.image = [image circleImage];

    }];

}

- (void)setHeaderUrl:(NSString *)url withplaceholderImageName:(NSString *)placeholderImageName

{

    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:placeholderImageName] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

        if (image == nil) return;

        self.image = [image circleImage];

    }];

    

}

 

@end

posted @ 2019-01-25 09:35  sundaysios  阅读(133)  评论(0编辑  收藏  举报