Make UIView and subviews translucent as one layer,

2019-05-31 10:35发布

问题:

When setting the alpha of a UIView (on iOS) it sets each subview to the same value, but composites them with that alpha on top of their respective superviews. So the subviews are blended with their superviews.

I don't want this to happen. I want the opacity to be applied to the UIView as a whole, not to each individual view. I want to achieve the same effect as, say, CSS3's opacity, or applying opacity to a group of layers in Photoshop, rather than to each layer individually.

The complexity however is that in this UIView is a UITableView and others that need to be interactive. And it's not viable to have the view that is supposed to be behind this view on top instead.

My question is: What's the best way to achieve this?

Thank you!
Alec

回答1:

There's a 'Renders with group opacity' setting in Info.plist

Documentation here: http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

(Search for the mentioned setting).