Can you redefine the parent value of the alpha version of UIView in one of your subzones?

I have a somewhat transparent view (alpha = 0.6), which has some subspecies. I would like one of the subtitles (UILabel) to be drawn with alpha 1.0, because mixing makes the text difficult to read, but, adding it as a subitem of the main view, it accepts its parent alpha value. Is there any way to undo this behavior? I believe that I will have to remove it from the subtitle, but I wanted to ask and see, maybe I missed something.

+6
cocoa-touch uiview alphablending
source share
3 answers

You're right. You will need to migrate the UILabel from the transparent view so that it appears as opaque.

+2
source share
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 will not be affected.

+13
source share

Another approach that worked easily was not to change the alpha channel in the UIView. Instead, change the alpha layer on the backgroundColor UIView object.

Of course, it depends on why you made a transparent alpha layer, but it worked well for my requirements.

+10
source share

All Articles