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

    }];

相關文章
相關標籤/搜索