1

我有一个包含文本字段的应用程序。

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

4

4 回答 4

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];
于 2012-06-23T10:25:02.947 回答
2

您可以在 Xamarin 中使用下面提到的代码进行设置

txtNumber.BackgroundColor = UIColor.White;
txtNumber.Alpha = 0.5f;

参考1:透明UITextView 参考2:如何创建透明的UITextField?

相似之处:

txtNumber.BackgroundColor = UIColor.Clear;

于 2014-07-25T05:01:26.000 回答
1

只需为白色背景输入波纹管代码

[yourTextField setBackgroundColor:[UIColor whiteColor]];

或者如果想清除颜色然后下面的代码

 [yourTextField setBackgroundColor:[UIColor clearColor]];

很简单

:)

于 2012-06-23T09:30:15.910 回答
1

使用自定义 UITextField

UITextField *yourTextField= [[UITextField alloc] initWithFrame:frame];
yourTextField.borderStyle = UITextBorderStyleNone;
[yourTextField setBackgroundColor:[UIColor clearColor]];
于 2012-06-23T09:34:25.950 回答