原本代码,升级后不显示图片了:
[photoImageView setCircleImageWithUrl:tempurl placeholder:[UIImage imageNamed:@"me_photo"] err:[UIImage imageNamed:@"me_photo"]];
- (void)setCircleImageWithUrl:(NSString *)url placeholder:(UIImage *)image err:(UIImage *)eImage
{
[self circle];
[self setImageWithUrl:url placeholder:image err:eImage];
}
#pragma mark - Circle
- (void)circle
{
[self.layer setMasksToBounds:YES];
self.layer.cornerRadius = self.frame.size.width/2;
}
- (void)setImageWithUrl:(NSString *)url placeholder:(UIImage *)image err:(UIImage *)eImage
{
__weak __typeof(self) safeSelf = self;
[self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:image completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (error) {
safeSelf.image = eImage;
} else {
safeSelf.image = image;
}
}];
}
修改方法,将设置圆角的方法,放到加载完图片的block方法中,即可显示圆角图片,具体原因不清楚
修改代码:
- (void)setCircleImageWithUrl:(NSString *)url placeholder:(UIImage *)image err:(UIImage *)eImage
{
[self circle];
__weak __typeof(self) safeSelf = self;
[self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:image completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
if (error) {
safeSelf.image = eImage;
} else {
safeSelf.image = image;
}
[self.layer setMasksToBounds:YES];
self.layer.cornerRadius = self.frame.size.width/2;
}];
}