Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Steven-Yung opened this issue Dec 28, 2016 · 5 comments

Comments

@Steven-Yung
Copy link

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

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

    }];

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

@GhostZephyr
Copy link

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

@0xxxD
Copy link

0xxxD commented Mar 11, 2017

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

@Homin818
Copy link

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

@Homin818
Copy link

#190

@XavierLost
Copy link

YYWebImageOptionIgnoreDiskCache 把这个用上就不会

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants