How can I colorize a black/white UIImageView programmatically?

Viewed 1118

I have a set of black and white images, like below. If I remember correctly, there's some way to set the blending or masking property of a UIImage to blend it with the background UIView.

In this case, I want to change the color of this image to red to signify hit points. How can I programmatically change the color of this UIImage?

I know about the use of image filters, in particular hue shift, but they are really resource intensive, plus they don't work on white image, so I'm looking for another solution.

Example icon

I tried overlaying a UIView with alpha 0.4 and setting it's background color to red, here's the result :

enter image description here This may work in some cases, but in my case I would like to have more control over the shade of color I'm getting.

2 Answers
Related