Reputation: 697
I have for example this icon:
this is the color of the icon when its not clicked .. when i click it it will change the color as shown below:
what is the best way to achieve that? is there is a way to do it as a font icon and change the color of it? or shall i just change the image when clicked and unclicked?
can someone please tell me the best way to do it...
Upvotes: 1
Views: 241
Reputation: 16160
Use rendered image
var renderedIcon: UIImage? = UIImage(named:"myImage")?.withRenderingMode(.alwaysTemplate )
imageView.image = renderedIcon
imageView.tintColor = //Normal Color
Change the tintColor
when button clicked.
OR
You could set
myButton.setImage(UIImage(named : "unselectedImage"), forState: UIControlState.Normal)
myButton.setImage(UIImage(named : "selectedImage"), forState: UIControlState.Selected)
Upvotes: 3