Chained animations with PhaseAnimator
In iOS 17, Apple introduced new and powerful animation APIs. With the PhaseAnimator container view we can finally apply a series of animations chained together. PhaseAnimator animates its content automatically by cycling through a collection of values, named phases, each defining a step within the animation. We can also apply the phaseAnimator(_:content:animation:) view modifier to obtain the same result. We will see how to use the PhaseAnimator container and the phaseAnimator(_:content:animation:) view modifier in this recipe.
Getting ready
No external resources are needed, so let's just create a SwiftUI project in Xcode called ChainedAnimations.
How to do it…
To illustrate how PhaseAnimator and phaseAnimator(_:content:animation) work, we will use some images and animate some of the properties:
- In ContentView modify the struct with the following:
struct ContentView: View {
@State var trigger = false
var body: some View ...