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.
You are correct. You'll have to move the UILabel out of the transparent view to get it to render as non-transparent.
I don't think the previous answer was correct.
Views do not inherent the alpha of their parent view. You can set the alpha property independently for each view. For example, you can add a completely opaque view as a subview of a completely transparent one. You can also change alpha on the fly programatically.
Depending on the order of views and their alphas you might get unexpected blending effects but you can compensate by adjusting the ordering of your views.
Another approach which worked easily is to not modify the alpha channel on the UIView. Instead, modify the alpha layer on the backgroundColor object of the UIView.
Of course this depends on why you made the alpha layer transparent, but it worked well for my requirements.
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.