简体   繁体   中英

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. Is that true?

Is there a way to change the alpha on just the background and not effect the text?

Yes, changing the alpha for the UITextView or UITextField affects the entire control. If you want to adjust the alpha of the background, specify the alpha of the UIColor for the 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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM