层是什么有益的?添加图层怎么办?为什么要考虑图层? [英] What are Layers good for? What could I do with adding an Layer, and why should I think about Layers?

查看:118
本文介绍了层是什么有益的?添加图层怎么办?为什么要考虑图层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是什么让Layers与Views不同,当每个View都带有它自己的Layer时。也许我错了。但那么:这些图层有什么用呢?

I am wondering what makes Layers different from Views, when every View comes along with it's own Layer. Maybe I am wrong with that. But then: What are these Layers good for?

就像我理解的那样,我会使用UIView在GUI中对元素进行分组。我也可以使用UIView来定位其他东西。那么Layers到底在哪里?

Like I understand it, I would use an UIView to group elements in my GUI. I could also use that UIView to position things over other things. So where come Layers into place here?

我是否应该像在HTML / CSS中那样将它们视为z-index?它们对核心动画的东西有用吗?

Should I think of them just as the z-index like in HTML / CSS? Are they just interesting for Core Animation stuff?

推荐答案

与UIVIews相比,CALayers

Compared to UIVIews, CALayers are


  • 轻量级

  • 充满了动画的时间信息

  • 有些东西比文字更难画(尤其是unicode)。

如果你的数量少于20个,那可能无关紧要。如果您有复杂的动画需求,或只需要绘制大量图层,您可能会因使用CALayers而受益。

If you have less than 20 or so of them, it probably doesn't matter. If you have complicated animation needs, or just a ton of layers to draw, you may benefit from using CALayers instead.

这篇关于层是什么有益的?添加图层怎么办?为什么要考虑图层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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