Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode view transparent background without influencing subviews

I want to program a custom keyboard for a textfield. The background of the keyboard should be transparent, but when I try to set the alpha of the keyboardView, the alpha of its subviews changes too. How can I change the keyboard's alpha only? I don't want to set it to [UIColor clearColor].

keyboardView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
keyboardView.alpha = 0.2;
keyboardView.backgroundColor = [[UIColor clearColor] colorWithAlphaComponent];
like image 934
Josef Büttgen Avatar asked Nov 20 '25 20:11

Josef Büttgen


1 Answers

Changing a view's alpha alters the view and all it's subviews.

If you want the non-drawn parts of your view to show what's underneath, set the view's opaque flag to NO and then set the background color to clearColor.

like image 131
Duncan C Avatar answered Nov 23 '25 10:11

Duncan C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!