When I try to change button's image when button pressed but it just shows a blue square as button's image
@IBAction func button(_ sender: Any) {
buttonOutlet.setImage(#imageLiteral(resourceName: "thing"), for: UIControl.State.normal)
}
When I try to change button's image when button pressed but it just shows a blue square as button's image
@IBAction func button(_ sender: Any) {
buttonOutlet.setImage(#imageLiteral(resourceName: "thing"), for: UIControl.State.normal)
}
From Apple documentation:
A control becomes highlighted when a touch event enters the control’s bounds...
Highlighted state of a control
button.setImage(UIImage(named: "button_normal_state"), for: .normal)
button.setImage(UIImage(named: "button_pressed_state"), for: .highlighted)
Just recheck that you have "thing" - image in your target.
button.setImage(UIImage(named: "thing"), for: [.selected, .highlighted])
And see this question UIButton: set image for selected-highlighted state