读书笔记 --- Layer(一)

2015-08-28  本文已影响0人  ZhouJialei

Overview

layer is the partner of its view ,a view is not redrawn frequently, its drawing is cached and the cached version is the layer.The view's graphics context is the layer's graphics context.


View & Layer

example

class CompassView: UiView {
    override class func layerClass() -> AnyClass {
        return CompassLayer.self
    }
}

** but you must never set the delegate property of a UIView's underlying layer to break the integration between them **

Layers & Sublayers

A hierarchy of views and the hierarchy of layers underlying it Layers that have sublayers of their own

Manipulating the Layer Hierarchy

Layers come with a full set of methods for reading and manipulating the layer hierarchy, parallel to the methods for reading and manipulating the view hierarchy.

Positioning a Sublayer

Layer coordinate systems and positioning are similar to those of views. A layer's own internal coordinate system is expressed by its bounds, just like a view; its size is its bounds size, and its bounds origin is the internal coordinate at its top left.

CAScrollLayer

If you move a CAScrollLayer's bounds origin, you are repositioning its sublayers at the same time.It is a CALayer subcalss but it provides no scrolling interface. By default, a CAScrollLayer's masksToBounds property is true.

Layout of Sublayers

There is automatic layout for layers if they are the underlying layers of views. Otherwise, there is no automatic layout for layers in iOS.

上一篇 下一篇

猜你喜欢

热点阅读