本文介绍了视图的 hidden = yes 和 alpha = 0.0f 有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个关于 UIView
的问题,隐藏视图、alpha 视图和不透明视图之间有什么区别?
I have a question about UIView
, what's the difference between views hidden, alpha and opaque?
设置view的效果:hidden = yes和view.alpha = 0.0f是一样的.
The effect of setting view: hidden = yes and view.alpha = 0.0f is the same.
推荐答案
差异很微妙.根据 UIView 类参考:
opaque
告诉系统视图没有透明度,因此渲染速度更快,因为可以跳过混合计算hidden
是布尔属性,它仅更改当前视图的可见性并将其从 ui 事件中隐藏.alpha
是一个动画属性
opaque
tells the system that the view has no transparency and is thus faster to render because calculations for blending can be skippedhidden
is boolean property that changes only the visibility of the current view and hides it from ui events.alpha
is an animatable property
设置 alpha = 0.0f
或 hidden = YES
具有相同的视觉效果.然而,当您有大量嵌套视图时,使用 hidden
不仅在图形意义上而且从 ui 事件中实际隐藏视图可能会导致更有效的响应者链.
Setting alpha = 0.0f
or hidden = YES
has the same visual effect.However using hidden
to actually hide a view not only in a graphical sense but also from ui events might result in a more efficient responder chain when you have lots of nested views.
这篇关于视图的 hidden = yes 和 alpha = 0.0f 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!