How can I colorize a black/white UIImageView programmatically?

前端 未结 2 1064
一向
一向 2021-02-10 13:37

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:25

    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.

提交回复
热议问题