Hi,
In many cases we have to give a background color to a superview with alpha less than 1.0. If we give color from XIB/storyboard to a superview with alpha 0.4 then it assigns the alpha 0.4 to its subviews also.
What if we need to give alpha 0.4 only to the superview. There is a simple code for it.
Assign the color to the superview as below:
[self.blueView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.4]];
This way the alpha 0.4 will be given only to the superview and not to the sub views.
Check screenshot below:
![](http://findnerd.s3.amazonaws.com/imagedata/2529/2529.png)
Here is the alpha 0.4 given from storyboard to superview. The alpha will be given to subviews as well.
Check screenshot below:
![](http://findnerd.s3.amazonaws.com/imagedata/2530/2530.png)
0 Comment(s)