Search code examples
swiftuibuttonsdwebimage

sd_setImage show blue image


I am using SDWebImage to set the cells button image:

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

but what I get is a blue image like that: I don't know why enter image description here


Solution

  • You need to use the sd_setBackgroundImage property since you are setting the background image of a button (UIButton), not setting an image to UIImageView.

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