Member-only story
The 2 Must-Know Protocols for SwiftUI Animation
Animatable and AnimatableModifier are essentials to create SwiftUI animations
When using SwiftUI, it’s important to animate views and transitions with silky smooth performance. This article introduces the two protocols for SwiftUI animation that every developer must know.
1. The Animatable Protocol
The Animatable
protocol is available on iOS 13+. It defines the type that can be animated. The only value the protocol contains is animatableData
which is the associated type of VectorArithmetic
. VectorArithmetic
extends the AdditiveArithmetic
protocol with scalar multiplication and a way to query the vector magnitude of the value. The Animatable
protocol helps us in animating paths and transforming matrices.
SwiftUI traverses the view hierarchy to find the values adopt Animatable
protocol and…