Learn how to use animations in your apps on iPhone and iPad
Core Animation underpins the user interface of virtually all iOS apps. Even if you don’t use the framework directly, it forms the base upon which the view classes rest, and has consequently played a pivotal role in the success of the platform.
In this hands-on workshop, you’ll learn how to leverage Core Animation in your own apps, to provide feedback to the user, and — dare we suggest — add delicious effects and other eye candy. We’ll start the day learning about utilizing Core Animation via the UIView class, before moving on to more advanced usage and the CALayer class. Numerous types of animations will be covered, from basic translations and rotations, to dissolves and advanced transforms. Techniques for producing sequences of animations will be discussed, and you’ll even learn how to apply and animate Core Image filters.
This one-day workshop will be very hands on, with the aim of imparting skills that you can take away and start using in your own software straight away. You will need to bring a laptop with Xcode installed, so that you can complete the exercises, and build and run examples.
The workshop will be based around a single, deceptively simple example: bouncing a ball. In the real world, bouncing a ball poses little challenge to most of us, but — as will become apparent as the day progresses — bouncing a virtual ball with Core Animation can be as simple or complex as you want to make it. Riffing on this one example will introduce all of the skills you need to incorporate Core Animation effectively in your own iOS apps.
Here is an outline of the day’s sessions:
- What is Core Animation, and what is it good for?
Introduction to the framework, explaining what it is good for, and — just as importantly — what it is not good for.
- UIView Animations.
How you use class methods in UIView to access basic features of Core Animation. We’ll start bouncing the ball, but only in very basic ways. We’ll also look at how timing is controlled in Core Animation, and how you can combine animations to make animated sequences.
- CALayer: The Unsung Hero.
Digging down into the Core Animation framework itself, we’ll meet CALayer, the class upon which everything depends. You’ll learn how to put content into your layers using Quartz drawing, or an existing image.
- Implicit Animations.
You get a lot for free with Core Animation. Often you don’t need to write any code at all to produce great animations. In this section, you’ll learn how that works, and how you can set default animations for your layers which are triggered by events.
- Explicit Animations.
Sometimes you can’t leave it to chance: you need to get down and dirty, and build your animations up by hand. In this session you’ll be introduced to explicit animations, and the two most important animation classes: CABasicAnimation and CAKeyframeAnimation. We’ll start to bounce the ball in more creative ways, including accounting for inelasticity to improve realism.
You can apply advanced mathematical transforms to layers to create interesting effects. Translate, rotate, scale, skew, and everything in between. What’s more, transforms are fully animatable. We’ll use some of these transforms to add more physical effects to the ball, squashing it on impact, and introducing spin and wobble.
- Other Layer Classes and Effects.
In this session, we’ll look at some of the more obscure aspects of Core Animation. Layer classes to create gradients, shapes, and even particle effects. We’ll also learn how to apply and animate Core Image filters. Your balls will never look the same again.