8.7 · Animations, PhaseAnimator, Canvas and TimelineView
In SwiftUI you do not animate views, you change state inside an animation context and the framework interpolates the difference. Drawing is a separate escape hatch for when views are too heavy.
Mental model. An animation is a change of state plus a curve. If SwiftUI can interpolate the value, it animates; if the identity changes, it uses a transition instead.
Animating changes
Implicit, explicit, transitions and keyframes.
- What is the difference between implicit and explicit animation, and how do transitions fit in?
An implicit animation is attached to a view: .animation(.spring, value: flag) animates changes to that value in everything above the modifier. Always pass a…
Drawing and time
<code>PhaseAnimator</code>, <code>Canvas</code> and <code>TimelineView</code>.
- When do you use PhaseAnimator, Canvas and TimelineView?
PhaseAnimator cycles a view through a list of phases (any Sequence of values), applying a content closure per phase and an animation closure for each…
More in SwiftUI
- 8.1 · What a View is, and how SwiftUI knows which view is which
- 8.2 · The update loop, dependency tracking and the cost of body
- 8.3 · State, Binding, Environment and Observation
- 8.4 · onAppear, task, onChange and scenes
- 8.5 · The layout negotiation, stacks, GeometryReader, safe area and custom Layout
- 8.6 · Lists, ForEach and NavigationStack
- 8.8 · Preference keys and coordinate spaces
- 8.9 · Previews and the macros behind SwiftUI
- 8.10 · State, bindings, Observation and environment, checked by running them
- 8.11 · The order of events in a render, and what Swift 6 isolation means for views
- 8.12 · Sharing space, alignment guides, adaptive containers and grids, measured
- 8.13 · What a ViewBuilder produces, and saving and restoring a navigation path