2012-06-23 52 views
0

我有一个包含文本字段的应用程序。文本字段的背景透明度

有没有办法在代码中更改此文本字段的背景透明度?

+0

你想要什么背景颜色与清晰的颜色? –

+0

是的确切我不想任何背景颜色 – Alippo

+0

然后使用此代码我粘贴代码与ClearColor波纹见下面我clearColor的代码:) –

回答

1

只要将波纹管代码白色背景

[yourTextField setBackgroundColor:[UIColor whiteColor]]; 

,或者如果想清除的颜色,然后娄代码

[yourTextField setBackgroundColor:[UIColor clearColor]]; 

这么简单

:)

1

使用Custom UITextField

UITextField *yourTextField= [[UITextField alloc] initWithFrame:frame]; 
yourTextField.borderStyle = UITextBorderStyleNone; 
[yourTextField setBackgroundColor:[UIColor clearColor]]; 
+0

参考[自定义UITextField](http://www.roseindia.net/answers/viewqa/Mobile-Applications/15639-UITextField-Programmatically-iPhone.html) – Hector

2

是的,你可以做到这一点。

您可以通过设置透明度来设置透明度。您可以使用数字色彩表(它是Mac中的内置应用程序)来拍摄彩色代码。

如果设置了alpha 1,那么将不会有透明度。根据您的需要设置透明度(将alpha设置为小于1)。

试试这个:

textfield.backgroundColor=[[UIColor colorWithRed:208.0/255.0 green:15.0/255.0 blue:202.0/255.0 alpha:0.6] CGColor]; 
+0

嘿朋友,如果你想背景透明或清除setBackground的颜色clearColor只有一个简单的线代码伙计...喜欢.. [yourTextField setBackgroundColor:[UIColor clearColor]]; :) –

+1

@ParasJoshi您对使用clearColor的简单性是正确的,但这仍然是一个很好的例子。这个答案是提问者基本颜色操作的一个很好的总结。为你们两个+1! –