[英]Does changing alpha value change text?
For a UITextView or UITextField, when the alpha value is changed, it seems to change the text as well. 对于UITextView或UITextField,当更改Alpha值时,似乎也更改了文本。 Is that true? 真的吗?
Is there a way to change the alpha on just the background and not effect the text? 有没有办法只在背景上更改Alpha而不影响文本?
Yes, changing the alpha
for the UITextView
or UITextField
affects the entire control. 是的,更改UITextView
或UITextField
的alpha
会影响整个控件。 If you want to adjust the alpha of the background, specify the alpha
of the UIColor
for the backgroundColor
. 如果你想调整背景的α,指定alpha
的的UIColor
的backgroundColor
。
For example, for a translucent red background you could do: 例如,对于半透明的红色背景,您可以执行以下操作:
textView.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.1];
or 要么
textView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.1];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.