iOS控制子视图的UIView alpha行为 [英] iOS controlling UIView alpha behaviour for subviews

查看:106
本文介绍了iOS控制子视图的UIView alpha行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的示例中,我有3个视图:一个包含两个白色视图的红色视图。我将红色容器视图的alpha更改为0.3并且发生这种情况(查看图像,当前结果)。

In my example, I have 3 views: one red view containing two white views. I change the red container view's alpha to 0.3 and this happens (look at the image, the current result).

通过看到这一点,我只能假设(告诉我,如果我错了)设置视图的alpha也将设置其所有子视图的alpha。我的问题是:有没有办法简单地告诉红色视图作为一个整体,以便设置其alpha会给出看起来像想要的结果(在图像中)?

By seeing this, I can only assume (tell me if I'm wrong) that setting a view's alpha will also set all of its subviews' alphas. My question is : is there a way to simply tell the red view to act as a whole so that setting its alpha would give something that looks like the wanted result (in the image)?

这是没有任何alpha的情况:

This is what it looks like without any alpha :

推荐答案

查看Info.plist可能的UIKit密钥,特别是 UIViewGroupOpacity

Check out the possible UIKit keys for Info.plist, specifically UIViewGroupOpacity.


UIViewGroupOpacity (布尔值 - iOS)指定Core Animation是否为
子图层继承其超级图层的不透明度。

UIViewGroupOpacity (Boolean - iOS) specifies whether Core Animation sublayers inherit the opacity of their superlayer.

Info.plist UIKit Keys

这篇关于iOS控制子视图的UIView alpha行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆