Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you override a parent UIView's alpha value on one of its subviews?

I have a somewhat transparent view (alpha = 0.6) that has some subviews. I'd like one of the subviews (a UILabel) to be drawn with alpha of 1.0 because the blending makes the text difficult to read but by adding it as a subview of the main view it has adopted its parent's alpha value. Is there a way to override this behavior? I believe I'll have to remove it from the subview but wanted to ask and see if maybe I'm missing something.

like image 662
Meltemi Avatar asked Aug 13 '09 01:08

Meltemi


1 Answers

Brian is right. For example :

view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];

will make a Black background in alpha 0.6 and other views won't be affected.

like image 185
Pierre Valade Avatar answered Oct 02 '22 06:10

Pierre Valade