Written by Marin Todorov
There’s no denying it: Creating animations is one of the most enjoyable parts of iOS development!
Animations are fun to create, they breathe life into your user interface, and most importantly, they make your interface a delight to use. Who doesn’t love an app that gives you a little visual thrill when you open a menu or swipe right?
You’ve probably seen impressive animations in many third-party apps, as well as in Apple’s own built-in apps. When used properly, animations can convey information to your users and draw their attention to important parts of the interface.
To create responsive and attractive user interfaces, you’ll need to use all kinds of animations, from very subtle effects, to extremely expressive ones that leap off the screen.
In this book, you’ll learn about various iOS animation techniques, from simple view animations, to vivid 3D animations, to view controller animations that make the navigation in your app look and feel great.
By the end of this book, you’ll have worked through the chapter content and you’ll have hands-on experience solving the challenges at the end of the chapters — and you’ll be well on your way to coming up with stunning animations for your own apps!
Who this book is for
This book is for iOS developers who already know the basics of iOS and Swift, and want to dive deep into animations.
If you are a complete beginner to iOS development, we recommend you read through The UIKit Apprentice first. Otherwise this book may be a bit too advanced for you.
This book does require some basic knowledge of Swift. If you do not know Swift, you can still follow along with the book because all of the instructions are in step-by-step format. However, there will likely be parts that are confusing due to gaps in your knowledge.
Before beginning this book, you might want to go through our Swift Apprentice series, which covers the basics of Swift development:
As with raywenderlich.com, all the tutorials in this book are in Swift.
How to use this book
Each chapter in this book includes a starter project and covers a small number of animation techniques in detail; this lets you work through the chapters in the book in any order.
However, for beginners, we do suggest that you work through the chapters in order, since the concepts build upon each other. Also, remember you’ll get the most out of the book if you follow along with the tutorials and perform the hands-on challenges.
For advanced developers, there’s still value in the early chapters since that cover the basics, since you might not yet be familiar with the Swift syntax for these familiar animation APIs. However if you’re comfortable with that, feel free to jump ahead to the topics that interest you the most.
What’s in store
This book is divided into seven sections. You can find more details on each section in its introduction, which also includes a short description of its chapters. Here’s a brief overview.
Section I: Animations With SwiftUI
SwiftUI is a modern, cross-platform, declarative UI framework introduced by Apple in iOS13. It’s a big departure from how you used to build UI and animations in earlier iOS versions but it’s also a lot of fun to work with and you will quickly get to build some truly stunning effects.
Section II: View Animations
UIKit View animations are the most common type of animations in iOS, but still very powerful; you can easily animate almost any view element and change things such as its size, position and color.
Section III: Auto Layout
Auto Layout is becoming more common in apps, and there are some special techniques to animate views that are sized and positioned with auto layout constraints. This section provides a crash course in Auto Layout and then covers the animation techniques that play nicely with Auto Layout.
Section IV: Layer Animations
Views on iOS are backed by layers, which offer a lower-level interface to the visual content of your apps. When you need more flexibility or performance, you can use layer animations rather than view animations. In this section, you’ll learn about layers and the Core Animation API.
Section V: View Controller Transition Animations
Animating views and layers is impressive, but you can dial it up to 11 and animate entire view controllers! In this section, you’ll learn the techniques for transitioning between view controllers, as well as transitioning between changes in device orientations, all in the same view controller.
Section VI: Animations With UIViewPropertyAnimator
UIViewPropertyAnimator, introduced in iOS10, and helps developers create interactive, interruptible view animations. Since all APIs in UIKit just wrap that lower level functionality, there won’t be many surprises for you when looking at
UIViewPropertyAnimator. This class does make certain types of view animations a little easier to create, so it is definitely worth looking into.
Section VII: 3D Animations
In this section, you’ll move beyond two dimensions and learn about 3D animations and effects with CATransform3D. Although Core Animation isn’t a true 3D framework, it lets you position things in 3D-space and set perspective – which leads to some very slick and impressive effects!