在Interface Builder中更改TextField中的背景颜色 [英] Changing background colour within a TextField in Interface Builder

查看:94
本文介绍了在Interface Builder中更改TextField中的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将文本字段内的颜色设置为与默认白色不同的颜色。

I want to be able to set the color inside a Text Field to be a different color than the default white.

我可以通过减少Alpha使其变灰值,但我想使用灰色以外的颜色来表示某些条件。即红色警告。

I can make it grey by reducing the Alpha value but i want to use colors other than gray to denote certain conditions. i.e. red for a warning.

我讨厌问这么简单的问题,但我做了一些谷歌搜索,但没有看到任何东西给我一些见解。

I hate asking such a simple question but I did some Google Searches and don't see anything to give me some insight.

我想使用颜色,而不是图像,因为它比使用图像更有效。但是如果它只适用于图像,那么对它的指导就会很棒。

I want to use colors, not an image as that would be more efficient than using images. But if it only works with images then guidance on that would be great.

我知道你可以设置一个背景图像,但更多的是使边框变得不同颜色。我希望文本字段区域内的颜色是不同的颜色。

I know there is a Background image you can set but that is more to make the border a different color. I want the color inside the text field area to be a different color.

如果有办法在代码中执行此操作但不在IB中执行此操作,那么这对于我也是。

If there is a way to do this in code but not in IB, that would be useful for me as well.

谢谢,

Dano

推荐答案

要更改IB中的背景颜色,请将边框设置为圆形矩形以外的其他颜色。

To change the background color in IB, set the Border to other than round rect.

以编程方式:

UITextField *myTextField;
myTextField.borderStyle = UITextBorderStyleNone;
myTextField.backgroundColor = [UIColor redColor];

这篇关于在Interface Builder中更改TextField中的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆