Unable to change the UI image for different states

advertisements

I want to change the image of a UIButton for different states. To achieve this, I'm using:

btn.setImage(UIImage(named: "blabla"), for .normal)

and

btn.setImage(UIImage(named: blabla2), for .disabled)

This only makes some appear dimmed.

What did I do wrong? I just want to make my button appearance the same for different states, how?

(my button type - .system).


You just need to set one for the state. And if you don't set another image for different state. It would look the same in all state.

button.setImage(image, forState: .Normal)

How to change UIButton image in Swift