I have a button which is supposed to change image when it is clicked but for some reason it is not changing to the image set for the UIControlState.Highlighted state
override func viewDidLoad() {
super.viewDidLoad()
let versusButtonClickedImage = UIImage(named: "versus_button_cicked") as UIImage
let versusButtonImage = UIImage(named: "versus_button") as UIImage
versusButton.setImage( versusButtonImage, forState: UIControlState.Normal)
versusButton.setImage(versusButtonClickedImage, forState: UIControlState.Highlighted)
}
You have to add extension of image.
And no need to create separate variables of image.
testBtn.setImage(UIImage(named:"a1.png"),forState:UIControlState.Normal)
testBtn.setImage(UIImage(named:"a2.png"),forState:UIControlState.Highlighted)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With