CALayer 的目的? [英] Purpose of CALayer?
问题描述
我对 CALayer 存在的目的是什么有点习惯了.为什么不直接将属性放在 UIView 中?
I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView?
谢谢.
推荐答案
CALayer 代表与 UIView 完全不同的事物".CALayer 只处理绘图本身,并封装执行此操作所需的信息.另一方面,视图拥有一个或多个图层,用于绘制自身.但是,视图还有许多其他功能和属性,这些功能和属性与其在屏幕上的表示无关.
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.
我建议深入研究 Apple 文档,也许还可以找一本关于面向对象编码的书.
I would recommend digging into the Apple documentation, and maybe picking up a book on Object Oriented coding.
这篇关于CALayer 的目的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!