Home > Mobile >  how to set a background image of a button to nothing
how to set a background image of a button to nothing

Time:08-29

In my swift code I want to have a state fro the button that displays no image. It should be completely blank. I tried to do that with my swift code below but I am getting a error message no matches in call to initializer.

 BTN.setImage(UIImage(nil), for: .selected)

CodePudding user response:

You want the whole image to be nil rather than passing nil to the UIImage initializer. Try this:

BTN.setImage(nil, for: .selected)
  • Related