phaseAnimator
Animates effects that you apply to a view over a sequence of phases that change continuously.
Overloads
2 ways to call compose().phaseAnimator(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().phaseAnimator<Phase>(
phases: unknown[],
options: {
content: (value: any) => ViewModifierChain;
animation?: { returns: SwiftUI.Animation | null; perform?: (arg0: Phase) => void; };
}
)nonisolated func phaseAnimator<Phase>(
_ phases: some Sequence,
@ContentBuilder content: @escaping (PlaceholderContentView<Self>, Phase) -> some View,
animation: @escaping (Phase) -> Animation? = { _ in .default }
) -> some View
where Phase : EquatableParameters
phases*unknown[]The sequence of phases to cycle through. Ensure that the sequence isn't empty. If it is, SwiftUI logs a runtime warning and also returns a visual warning as the output view.
options.content*(value: any) => ViewModifierChainA content builder closure that takes two parameters: a proxy value representing the modified view and the current phase. You can apply effects to the proxy based on the current phase.
options.animation{ returns: SwiftUI.Animation | null; perform?: (arg0: Phase) => void; }A closure that takes the current phase as input. Return the animation to use when transitioning to the next phase. If you return
nil, the transition doesn't animate. If you don't set this parameter, SwiftUI uses a default animation.
Discussion
When the modified view first appears, this modifier renders its
content closure using the first phase as input to the closure,
along with a proxy for the modified view. Apply effects to the
proxy --- and thus to the modified view --- in a way that's appropriate
for the first phase value.
Right away, the modifier provides its content closure with the value
of the second phase. Update the effects that you apply to the proxy
view accordingly, and the modifier animates the change for you.
As soon as the animation completes, the procedure repeats using
successive phases until reaching the last phase, at which point the
modifier loops back to the first phase.
See also
More in Animation.
- animationApplies the given animation to all animatable values within the body closure.
- contentTransitionModifies the view to use a given transition as its method of animating changes to the contents of its views.
- glassEffectTransitionAssociates a glass effect transition with any glass effects defined within this view.
- keyframeAnimatorLoops the given keyframes continuously, updating the view using the modifiers you apply in body.
- matchedGeometryEffectDefines a group of views with synchronized geometry using an identifier and namespace that you provide.
- matchedTransitionSourceIdentifies this view as the source of a navigation transition, such as a zoom transition.
- scrollTransitionApplies the given transition, animating between the phases of the transition as this view appears and disappears within the visible region of the containing scroll view.
- springLoadingBehaviorSets the spring loading behavior this view.
- transitionAssociates a transition with the view.