aahrens aahrens - 1 year ago 108
iOS Question

How to apply a tintColor to a UIImage?

I have a

that is a small symbol that is all black. The
is getting set in a custom
subclass I have. Is it possible to have the image to apply the
to it, so instead of the black image it changes colors to whatever the

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];

Answer Source

If you are just supporting iOS 7 you can use tintColor and UIImageRenderingModeAlwaysTemplate

This article covers that:


If you need to support an earlier version you may want to consider this thread

How would I tint an image programatically on the iPhone?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download