iOS Core Animation Advanced Techniques

iOS Core Animation

I have never found Core Animation to be an easy framework to grasp so I was interested to see if this book could help. Read on for my review of iOS Core Animation: Advanced Techniques by Nick Lockwood (Published Aug 13, 2013 by Addison-Wesley Professional).

First Impressions

You can develop a lot of iOS apps without ever really being aware of the Core Animation framework. However sooner or later it is something you are going to want to understand. It may start with the desire to round the corners of a view which leads to copying some code from Stack Overflow:

someView.layer.cornerRadius = 10.0f;
someView.layer.borderWidth = 5.0f;
someView.layer.masksToBounds = YES;

If you want to know why this works and what the CALayer object is doing then this is the book for you. Actually it goes way beyond this trivial use of the framework to cover advanced animation and performance techniques as explained in the preface:

Although no prior knowledge of Core Animation is assumed, this is not merely a cursory introduction to the framework. The aim of this book is to leave no stone unturned when it comes to the Core Animation APIs.

The first section of the book dives deep into the CALayer hierarchy and static content. I read this section pretty much from beginning to end as it provides an excellent foundation to really understanding what Core Animation is. The second section is an exhaustive look at animation and the final section discusses performance. I have never considered myself a Core Animation expert so it was no surprise that I learned a lot from this book and will be referring back to it regularly.

In Depth

A deeper dive into the book contents:

Section I: The Layer Beneath

The first section of the book introduces the key concepts of the Core Animation framework. It was the section I found most useful in that it finally got me to understand what was going on under the covers.

Core Animation is a compositing engine; its job is to compose different pieces of visual content on the screen, and to do so as fast as possible.

Chapters in this first section cover the layer tree which mirrors the view hierarchy, how to work with and draw directly into the backing image of CALayer and manipulate the geometry of the layer. Visual effects such as rounded corners and drop shadows and transforms are covered but rather than just cut and pasting some code you get to understand how and why these effects work. This section finishes up with details on when to use each of the specialised Core Animation layers such as CAShapeLayer and CATextLayer.

Section II: Setting Things in Motion

After laying down the foundations the middle section of the book covers animation. This starts simple with the implicit animations that you pretty much get for free when changing an animatable CALayer property. The topics progress through explicit animations where you need specific control over the animation of a property, the CAMediaTiming protocol to control the timing of an animation, easing and timer-based animation.

Section III: The Performance of a Lifetime

The final section of the book covers performance and how to use Core Animation efficiently. The chapter on tuning for speed looks at how to determine if an animation is running slowly and what to do to fix it. There is a lot of good practical advice here on how to test and analyse Core Animation with Instruments. Further chapters cover efficient drawing, image IO and layer performance.


This book set out to be a complete guide to Core Animation which given the subject matter could be a difficult read. Luckily I think Nick achieves his aim without losing the reader in too much detail. I learnt a huge amount from this book and if you have any interest in Core Animation I think you will too. It definitely earns a place on my bookshelf.