Exploring layers
Layers are behind almost all the views you encounter in iOS, and they are the very base of anything you do with core animation.
The CALayer
class represents layers, and their main role is presenting content in a lightweight mode. The content is almost never drawn by the layer itself, but it is received as a bitmap, cached in a backing store, and then presented. You should look at layers as model objects rather than drawing elements; if there are any exceptions, it's probably because layers store the information needed to present some content generated somewhere else.
Layers and views
When a UIView
class is instantiated, it sets its layer
property with an instance of CALayer
that, under the hood, contains a backed bitmap version of the view. This method ensures an efficient and lightweight solution to draw and animate contents.
A relationship between the layer and view is immediately created during initialization, and the view becomes the delegate of the layer. From now on, a...