I have a UIImage
that is a small symbol that is all black. The UIImage
is getting set in a custom UIButton
subclass I have. Is it possible to have the image to apply the tintColor
to it, so instead of the black image it changes colors to whatever the tintColor
is?
I'm just trying to avoid creating new assets.
// here I want defaultImageName (that is black) to use the tintColor (that is white)
[self setImage:[UIImage imageNamed:defaultImageName] forState:UIControlStateNormal];
If you are just supporting iOS 7 you can use tintColor
and UIImageRenderingModeAlwaysTemplate
This article covers that:
https://www.captechconsulting.com/blogs/ios-7-tutorial-series-tint-color-and-easy-app-theming
If you need to support an earlier version you may want to consider this thread