注意:SDWebImage下载下来的网络图片默认展示图片本身的大小尺寸,因此要想改变图片的尺寸,必须在下面的方法中进行:
1 改变UIButton的图片尺寸: _iconBtn是已经有固定尺寸的button
[_iconBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:categoryProductModel.ImageURL] forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
image = [image stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];
[_iconBtn setBackgroundImage:image forState:UIControlStateNormal];
}];
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) {
image = [image stretchableImageWithLeftCapWidth:0.5 topCapHeight:0.5];
_iconView.image = image;
}];