The CALayer class manages image-based content and allows you to perform animations on that content. Layers are often used to provide the backing store for views but can also be used without a view to display content. A layer’s main job is to manage the visual content that you provide but the layer itself has visual attributes that can be set, such as a background color, border, and shadow. In addition to managing visual content, the layer also maintains information about the geometry of its content (such as its position, size, and transform) that is used to present that content onscreen. Modifying the properties of the layer is how you initiate animations on the layer’s content or geometry. A layer object encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines the layer’s timing information.
If the layer object was created by a view, the view typically assigns itself as the layer’s delegate automatically, and you should not change that relationship. For layers you create yourself, you can assign a delegate object and use that object to provide the contents of the layer dynamically and perform other tasks. A layer may also have a layout manager object (assigned to the layoutManager property) to manage the layout of subviews separately.
翻译:CALayer类管理以图片为基准的内容并且允许你去在内容上展示动画.图层面板(Layers)通常用来提供后台存储视图并且也可以不通过视图展示内容.图层面板(Layer)的主要工作是去管理那些你提供的可视的内容,但图层自身可以设置可视化属性,例如背景颜色,边界和阴影.为了管理可视化内容,图层也保留内容的几何形状信息(例如位置,尺寸,和形变)用来在屏幕上显现内容.修改图层的属性在于怎样启动图层内容或几何形状的动画.一个图层对象通过采用CAMediaTiming协议,该协议定义了图层的定时信息并且封装了图层的持续时间和调步以及动画.如果图层对象通过视图创建,视图通常自动分配自身作为图层的代理人并且你不应该改变这种关系.对于自己创建的图层,你可以指定一个委托对象,并使用该对象来动态地提供图层的内容以及执行其他任务。图层也可以有布局管理对象(指定布局管理属性)去分别管理子视图的布局.
网友评论