Setting alpha on UIView sets the alpha on its subviews which should not happen
I think this is a bug in the documentation. You should file it at bugreport.apple.com.
Everything I can see after a bit of quick research suggests what you are seeing is how it always has behaved, and my own testing shows it too.
The alpha of a view is applied to all subviews.
Perhaps all you need is [[UIColor blackColor] colorWithAlphaComponent:0.5]
but if not you will need to make the view a sibling instead of a child.
Don't set the alpha directly on the parent view. Instead of it use the below line of code which will apply transparency to parentview without affecting its child views.
[parentView setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.5]];
In swift
view.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.5)
UPDATED FOR SWIFT 3
view.backgroundColor = UIColor.white.withAlphaComponent(0.5)
Set Opacity of the background color instead of alpha will not affect its child views.
- select view.
- go to attribute inspector than background color
- click on "others"
- set opacity to 30%
Or you can set by programmetically
var customView:UIView = UIView()
customView.layer.opacity = 0.3
Thats it. Happy Coding!!!