如何在Xcode中更改图像的背景颜色?

时间:2012-04-05 08:27:37

标签: xcode

在我的程序中,我需要在GUI上添加一些图像。但是,图像的背景颜色与视图的背景颜色不同。 我知道有一个属性用于更改图像背景。但是,当我更改此项目的功能时,没有任何反应。在项目中添加图像之前,我是否会错过一些设置,以至于无法更改图像的背景颜色?非常感谢您的紧急帮助!

2 个答案:

答案 0 :(得分:1)

可以更改 ImageView的背景,但不能更改Image的背景。

您可以通过指定所需的ImageView颜色来实现。

[imageViewName setBackgroundColor:[UIColor redColor]];

或者您可以指定RGB值。

[imageViewName setBackgroundColor:[UIColor colorWithRed:0.5 green:0.0 blue:1 alpha:1.0]];

答案 1 :(得分:0)

您无法更改图像的背景。但您可以更改包含图像的imageview的背景颜色。