I need to change the Image of a UIButton in my NAV bar when a user taps it 3 times. Each tap displays a different UIImage and its corresponding collection view. I got the animated collection view working perfectly, but...
How do I get the button images to change in Swift?
I've tried multiple methods and can't seem to get it to work, for example:
@IBAction func buttonTapped(sender: UIButton) {
if let myButton = UIImage(named:"btn1") {
sender.setImage(myButton, forState: .Normal)
}
if let myButton = UIImage(named:"btn2") {
sender.setImage(myButton, forState: .Normal)
}
if let myButton = UIImage(named:"btn3") {
sender.setImage(myButton, forState: .Normal)
}
}
There are lots of posts relating to changing a uibutton for two states, e.g., stopwatch or play/pause, but I need 3 states in a navigation bar.
Thanks!