As we noted at the beginning of this chapter, the great thing about using CALayer
and its subclasses is that most of the properties are pre-configured for animation. How simple or how complex those animations are is entirely up to us, but it makes the implementation very easy.
In this section, we will start with some one-liner animation code and work our way up to some pretty intense 3D animations that will consist of a page of code each. But by using CALayer
objects to compose our slightly sci-fi inspired UI, we have completed much of the work that is needed to get Core Animation to do what it says on the box, namely animation.
Core Animation provides us with default animation of many of its property changes, which requires no extra code at all. Let's see this in action.
Add the following method to the ViewController
class:
func moveShapeLayer() { shapeLayer.position = CGPoint( x: customView.bounds.width * 0.5, ...