My question is when i added a view as subview to Root view.When i changed the alpha value of root view same is occurring in subview also.Actually i don't need the updating in subview.Is there any solution to do like that.
This will change only the alpha of the root view, not the others
self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];
Building on the answer by @shabbirv, one can also use IB's color picker
You'd need to change the structure of your views. Instead of laying your subviews out on the roots view, create a layer ontop of your root view, but still add the subviews to the root. When changing the layer's alpha it won't effect the subviews. Example structure below.
Your current structure:
RootView->Subviews //Changing RootView alpha effects Subviews.
Needed Structure:
RootView->View->Subviews(Still Added to RootView) //Changing alpha of Layer doesn't effect subviews.
Hope this helps.
This will also solve this by changing root view color by below way, this will not affect the subview.
[rootView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.7]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With