Using PhaseAnimator to Create Advanced Multi-Step Animations

Simon Ng
AppCoda Tutorials
Published in
5 min readAug 28, 2023

--

SwiftUI already streamlines the creation of view animations. One example is the matchedGeometryEffect modifier, which enables developers to define the appearance of two views. The modifier calculates the disparities between the two views and automatically animates the size and position changes. With iOS 17, Apple continues to improve the SwiftUI framework and provide a new view called PhaseAnimator, which allows us to build more sophisticated animations.

In this tutorial, we will explore the capabilities of PhaseAnimator and learn how to utilize it to create multi-step animations.

Building a Simple Animation with PhaseAnimator

The PhaseAnimator view, or the .phaseAnimator modifier, enables you to generate multi-step animations. By cycling through a collection of phases that you provide, each representing a distinct step, you can create dynamic and engaging animations.

Let me give a simple example, so you will understand how to work the phase animator. We will animate the transformation of a rounded rectangle. It begins as a blue rectangle, then scales up, changes color to indigo, and incorporates a 3D rotation animation.

We can use the RoundedRectangle view to create the rounded rectangle and attach the…

--

--

Simon Ng
AppCoda Tutorials

Founder of AppCoda. iOS Developer and Indie Entrepreneur. Love coffee, food and travel. http://www.appcoda.com