Reputation: 1586
One of my apps has three UIButtons
on it, and they use images that I got from icons8. In the code, I change the tint color and it works fine. Whatever I set the tint color to is what color the button image becomes that color.
Today I wanted to add a fourth button to mute sound. I downloaded the images that I wanted from icons8, added the button and set it up like I have the rest of the buttons set up. The new button is not changing colors like the rest of them. I'm certain that it has to do with the image, because if I select a different image, it changes color. I also tried using the new image on one of the older buttons and it would not change color.
My question - is there anything special that needs to be done to an image to make it work with tint color?
Upvotes: 1
Views: 1857
Reputation: 445
What I did was follow the @beyowulf instructions and on the code I just did this
yourBtn.tintColor = .white (or other color)
this worked for me
Upvotes: 0
Reputation: 15321
Try setting the image to render as a template image. You can do this in your .xcasset folder selecting the image set, opening the attributes inspector and setting render as to "template image."
Upvotes: 7