UIView clipsToBounds属性:它是否提高了性能? [英] UIView clipsToBounds property: Does it improve performance?

查看:127
本文介绍了UIView clipsToBounds属性:它是否提高了性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档说 UIView clipsToBounds 属性会将绘图剪切到边界,或者更确切地说是 subView 无法在 superView 的范围之外绘制。

The documentation says that the clipsToBounds property of UIView will clip the drawing to the bounds, or more precisely that the subView can't draw outside of the bounds of the superView.

听起来不错,但这在实践中意味着什么?

Sounds nice, but what does that mean in practice?

如果我将其设置为 YES ,那么我的 subView 将自动只绘制那些不在 superView 范围内的部分。所以它提高了整体性能还是我还要确保我不创建任何不可见的视图,即在 UIScrollView 中?

If I set that to YES, then my subView will automatically only draw those parts which are not outside the bounds of the superView. so it increases the overall performance or do I still have to make sure that I don't create any views that are not visible, i.e. inside a UIScrollView ?

推荐答案

我认为情况恰恰相反:开启剪辑会损害性能,因为它必须设置剪贴蒙版。我依旧记得在某个地方读过这个,但我现在找不到它。

I think it's the opposite: turning on clipping hurts performance because it has to set up a clipping mask. I vaguely remember reading this somewhere, but I can't find it now.

这篇关于UIView clipsToBounds属性:它是否提高了性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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