What are Layers good for? What could I do with adding an Layer, and why should I think about Layers?

前端 未结 2 1619
半阙折子戏
半阙折子戏 2021-02-06 16:13

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?

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 17:13

    Compared to UIVIews, CALayers are

    • lightweight
    • filled with timing information for animation
    • Some things are harder to draw, like text (esp. unicode).

    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.

提交回复
热议问题