sd_setImage显示蓝色图像

时间:2019-03-20 10:08:58

标签: swift uibutton sdwebimage

我正在使用SDWebImage设置单元格按钮图像:

cell.categoryButton.sd_setImage(with: URL(string:cell.image), for: .normal, placeholderImage: UIImage(named: "image"))

但是我得到的是一张蓝色的图像:我不知道为什么 enter image description here

1 个答案:

答案 0 :(得分:0)

由于您要设置按钮(sd_setBackgroundImage的背景图像,而不是将图像设置为UIButton,因此需要使用UIImageView属性。

cell.categoryButton.sd_setBackgroundImage(with: URL(string:cell.image), for: .normal, completed: nil)