UIView 隐藏属性...还有更多吗? [英] UIView hidden property...is there more to it?

查看:26
本文介绍了UIView 隐藏属性...还有更多吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 ActionScript,我将 Sprites 设置为 visible=false 以防止它们在布局等方面被计算,并确保它们不会响应事件.

Coming from ActionScript, I would set Sprites to visible=false in order to keep them from being calculated in things like layout, and to ensure they would not respond to events.

在 iOS 开发中,我将继续这样做——如果不需要 UIView,我可以将其 alpha 动画设置为零,然后设置 hidden=true.我想知道我是否在浪费时间,或者这是否有好处.在我当前的项目中,我使用 UIImageViews 这样做,它无论如何都不响应事件.

In iOS development, I am continuing with this--if a UIView is not needed, I may both animate its alpha to zero and then set hidden=true. I wanted to know if I was wasting my time, or if there is a benefit to this. In my current project, I'm doing so with UIImageViews which are not responding to events anyway.

设置隐藏是为了真正的良好实践,还是只是额外的开销?

Is setting hidden to true good practice, or or just additional overhead?

推荐答案

这是最好的选择,因为将 hidden 设置为 true 会从渲染循环中移除视图.将 alpha 设置为 0 只会使视图透明.

This is the best choice, because setting hidden to true removes view from the render loop. While setting alpha to 0 just makes view transparent.

这篇关于UIView 隐藏属性...还有更多吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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