YYWebImage icon indicating copy to clipboard operation
YYWebImage copied to clipboard

yy_setImageWithURL的transform block里面修改size和圆角都不生效

Open Steven-Yung opened this issue 8 years ago • 5 comments

用户头像需要调整大小和设置圆角,我用了这个方法

[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) {

    }];

结果图片还是原来的大小,并且圆角也没有生效,是不是哪里不对?

Steven-Yung avatar Dec 28 '16 03:12 Steven-Yung

用法问题 我这是好的 你调试看看

GhostZephyr avatar Feb 16 '17 04:02 GhostZephyr

试试 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) {
                                   
                               }];

0xxxD avatar Mar 11 '17 19:03 0xxxD

是缓存问题吧,试试清空缓存

Homin818 avatar Jun 23 '17 04:06 Homin818

https://github.com/ibireme/YYWebImage/pull/190

Homin818 avatar Jun 23 '17 04:06 Homin818

YYWebImageOptionIgnoreDiskCache 把这个用上就不会

XavierLost avatar Jul 18 '18 10:07 XavierLost