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

查看:35
本文介绍了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 (Boolean - iOS) 指定是否核心动画子层继承其上层的不透明度.

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

Info.plist UIKit Keys

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

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