Introducing CALayer
We could think of Core Animation layers as a lightweight version of NSView
. Layers don't come with many of the properties that we generally associate with views, particularly those associated with user interaction, but much of a view's appearance is in fact the product of its underlying layer.
Almost any CALayer
property is animatable--check the CALayer
docs for anything that is labeled CAAnimatable
.
Subclasses of CALayer
can implement the drawInContext
method to use Core Graphics drawing methods, or they can set a delegate that implements a drawLayer:inContext
method. But Core Graphics is a 2D framework, whereas CALayer
offers support for perspective and 3D drawing.
Creating a project
To look at what Core Animation can do, we'll need a window to view it in, so let's get that set up first:
- Create a new project and navigate to the
Main.storyboard
in the project navigator. - In the document organizer, expand the
Window Controller Scene
, then expand theWindow Controller
, and then...