简体   繁体   English

UIImage的透明颜色为白色

[英]transparent color to white for an UIImage

I realised that all my png images are defined with a transparent color instead of white color. 我意识到我所有的png图像都是用透明颜色而不是白色定义的。 I never noticed because the background of my app was white but now is of a different color. 我从未注意到,因为我的应用程序的背景是白色,但现在是不同的颜色。 And as I cannot edit each single png file to replace the transparent color to white, I am looking for a simple programmatic way of replacing on the fly the transparent color by a white color. 而且由于无法编辑每个png文件以将透明色替换为白色,因此我正在寻找一种简单的编程方式将飞行中的透明色替换为白色。 How should I do this please? 我该怎么办?

Thanks for any help 谢谢你的帮助

Cheers, geebee 干杯,吉蜂

如果我了解您要执行的操作,建议您为UIImageViews添加白色背景。

self.myImageView.backgroundColor = [UIColor whiteColor];

I don't see why you can't just "edit each single png file"; 我不明白为什么不能仅仅“编辑每个png文件”; it's a pretty much instant batch operation using GraphicConverter or ImageMagick or whatever. 这是使用GraphicConverter或ImageMagick或其他工具的几乎即时的批处理操作。

If you really insist on compensating for this on the device when the image loads, then just draw the image onto a white opaque rectangle and use the resulting composite image. 如果您确实坚持在图像加载时对此设备进行补偿,则只需将图像绘制到白色不透明矩形上,然后使用生成的合成图像即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM