SDWebImage设置UIImageView/UIButton的图片尺寸

注意:SDWebImage下载下来的网络图片默认展现图片自己的大小尺寸,所以要想改变图片的尺寸,必须在下面的方法中进行:网络

1 改变UIButton的图片尺寸: _iconBtn是已经有固定尺寸的buttonspa

[_iconBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:categoryProductModel.ImageURL] forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {orm

        image = [image stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];图片

        [_iconBtn setBackgroundImage:image forState:UIControlStateNormal];it

    }];下载

 

2 改变UIImageView的图片尺寸:_iconView为已经有固定尺寸的UIImageView方法

   [_iconView sd_setImageWithURL:[NSURL URLWithString:pointProductModel.ImageURL]  placeholderImage:[UIImage imageNamed:@"X-storeLoding"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {im

        image = [image stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];error

        _iconView.image = image;top

    }];

相关文章
相关标签/搜索