Skip to content

Instantly share code, notes, and snippets.

@iranjith4
Created June 20, 2016 15:25
Show Gist options
  • Save iranjith4/12a538857bdab9f7d9f946dbfd4af8d6 to your computer and use it in GitHub Desktop.
Save iranjith4/12a538857bdab9f7d9f946dbfd4af8d6 to your computer and use it in GitHub Desktop.
Wrong way of changing the image in UIButton
func myButtonTapped(){
if myButton.isSelected == true {
myButton.isSelected = false
myButton.setImage(UIImage(named : "unselectedImage"), forState: UIControlState.Normal)
}else {
myButton.isSelected = true
myButton.setImage(UIImage(named : "selectedImage"), forState: UIControlState.Normal)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment