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類管理以圖片為基準(zhǔn)的內(nèi)容并且允許你去在內(nèi)容上展示動畫.圖層面板(Layers)通常用來提供后臺存儲視圖并且也可以不通過視圖展示內(nèi)容.圖層面板(Layer)的主要工作是去管理那些你提供的可視的內(nèi)容,但圖層自身可以設(shè)置可視化屬性,例如背景顏色,邊界和陰影.為了管理可視化內(nèi)容,圖層也保留內(nèi)容的幾何形狀信息(例如位置,尺寸,和形變)用來在屏幕上顯現(xiàn)內(nèi)容.修改圖層的屬性在于怎樣啟動圖層內(nèi)容或幾何形狀的動畫.一個圖層對象通過采用CAMediaTiming協(xié)議,該協(xié)議定義了圖層的定時信息并且封裝了圖層的持續(xù)時間和調(diào)步以及動畫.如果圖層對象通過視圖創(chuàng)建,視圖通常自動分配自身作為圖層的代理人并且你不應(yīng)該改變這種關(guān)系.對于自己創(chuàng)建的圖層,你可以指定一個委托對象,并使用該對象來動態(tài)地提供圖層的內(nèi)容以及執(zhí)行其他任務(wù)貌笨。圖層也可以有布局管理對象(指定布局管理屬性)去分別管理子視圖的布局.