我在设置某些子视图的Alpha时遇到麻烦。
用故事板,我有一个UIView,viewA
在我的视图控制器,用subView1
,subView2
,和subView3
作为内部子视图viewA
。
当我将viewA
'alpha更改为0.5时,viewA
'alpha会更改,但其子视图的alpha保持不变。
默认情况下,不是根据其父视图更改子视图的Alpha吗?我究竟做错了什么?
干得好:
self.view.layer.allowsGroupOpacity = YES;
这将适用于所有子视图,子视图的子视图等等。
从文档:
* The default value of the property is read from the boolean
* UIViewGroupOpacity property in the main bundle's Info.plist. If no
* value is found in the Info.plist the default value is YES for
* applications linked against the iOS 7 SDK or later and NO for
* applications linked against an earlier SDK. */
您的项目可能未与iOS 7 SDK链接。如果您希望此更改适用于所有视图,请执行以下操作:
从苹果的文档:
UIViewGroupOpacity
“Renders with group opacity”
Specifies whether Core Animation layers inherit the opacity of their superlayer. See “UIViewGroupOpacity” for details.
iOS 3.0 and later
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句