Reputation: 44322
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?
Upvotes: 1
Views: 255
Reputation: 437632
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];
Upvotes: 2