UIImage change背景颜色
问题描述:
我们有从PhotoShop的图标设计,它是一个方形透明的图像,里面有一个蓝色的多边形。基于一些条件,我想改变多边形的颜色,但在完整的图像颜色。我们能做到这一点的代码(目标C)
我附上一个图像,其中只有背景“蓝”颜色需要根据我们给出的颜色被改变。我们如何achevie,
答
你可以通过渲染图像UIImageRenderingModeAlwaysTemplate
模式&之后,设置tintColor
。
imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[imageView setTintColor:[UIColor redColor]];
入住这https://*.com/a/36475407/7250862 –
是,在Objective C中有一条规定,以变更透明呈现图标的颜色。这里的过程https://*.com/questions/41545599/how-to-change-tintcolor-of-image-in-uibutton-with-imageedgeinsets/41547471#41547471 – Vishnuvardhan