Trying to dynamically change a button image.
reloadStopButton.currentImage = UIImage(named: "logo0.png")
Throws...
Cannot assign to the result of this expression
Grr.. Where did i go wrong?
Trying to dynamically change a button image.
reloadStopButton.currentImage = UIImage(named: "logo0.png")
Throws...
Cannot assign to the result of this expression
Grr.. Where did i go wrong?
You must use the button image setter:
reloadStopButton.setImage(UIImage(named: "logo0.png"), forState: UIControlState.Normal)
Button's need to know which state you are setting something for. This matters for things like their title
, titleColor
, and backgroundImage
too.
If you look at the docs for currentImage
you will see it is a readonly property. It just returns which image is currently being displayed. This can be useful for if you have different images showing for different states.