Purpose of CALayer?

允我心安 提交于 2020-02-04 02:40:48

问题


I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView?

Thanks.


回答1:


A CALayer represents a completely different "thing" from a UIView. A CALayer only deals with drawing itself, and encapsulating the information needed to do that. A view, on the other hand, owns one or many layers, which it uses to draw itself. A view has many other functions and properties though, that are unrelated to its representation on the screen.

I would recommend digging into the Apple documentation, and maybe picking up a book on Object Oriented coding.



来源:https://stackoverflow.com/questions/2962768/purpose-of-calayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!