iOS Core Animation Advanced Techniques

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.

Conclusions

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.

Never miss a post!

iOS Size Classes Cheat Sheet

Subscribe and get my free iOS Size Classes Cheat Sheet

Success! Now check your email to confirm your subscription and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

OK! Check your inbox (or spam folder) for an email to confirm your details and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
Archives Categories