YYWebImage
YYWebImage copied to clipboard
yy_setImageWithURL的transform block里面修改size和圆角都不生效
用户头像需要调整大小和设置圆角,我用了这个方法
[self.userAvatar yy_setImageWithURL:[NSURL URLWithString:model.portrait]
placeholder:placeholder
options:YYWebImageOptionIgnoreFailedURL
manager:[YYWebImageManager sharedManager]
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} transform:^UIImage * _Nullable(UIImage * _Nonnull image, NSURL * _Nonnull url) {
image = [image yy_imageByResizeToSize:placeholder.size contentMode:UIViewContentModeCenter];
[image yy_imageByRoundCornerRadius:5.0];
return image;
} completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
}];
结果图片还是原来的大小,并且圆角也没有生效,是不是哪里不对?
用法问题 我这是好的 你调试看看
试试 UIViewContentModeScaleToFill
[cell.avatarButton yy_setImageWithURL:[NSURL URLWithString:photo.avatarSmallURL]
forState:UIControlStateNormal
placeholder:nil
options:YYWebImageOptionProgressiveBlur | YYWebImageOptionShowNetworkActivity | YYWebImageOptionSetImageWithFadeAnimation
manager:nil
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
}
transform:^UIImage * _Nullable(UIImage * _Nonnull image, NSURL * _Nonnull url) {
@StrongObj(cell);
image = [image yy_imageByResizeToSize:cellStrong.avatarButton.frame.size contentMode:UIViewContentModeScaleToFill];
return [image yy_imageByRoundCornerRadius:cellStrong.avatarButton.frame.size.width/2];
}
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
}];
是缓存问题吧,试试清空缓存
https://github.com/ibireme/YYWebImage/pull/190
YYWebImageOptionIgnoreDiskCache 把这个用上就不会