xcodeswiftuitextfieldinterface-builderios8.2

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?


Solution

  • 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];