How can I colorize a black/white UIImageView programmatically?

前端 未结 2 1974
我在风中等你
我在风中等你 2021-02-10 14:05

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 backgrou

2条回答
  •  甜味超标
    2021-02-10 14:21

    The easiest way in this case would be to overlay a translucent red rectangle above the image. Since the image is black and white, the black areas will stay black. Change the height of the red rectangle to indicate different health levels.

    Just make a UIView with a red background color, not opaque, the same size as the UIImageView. Set the alpha of the background color to half or less.

提交回复
热议问题