keyframeAnimator
Loops the given keyframes continuously, updating the view using the modifiers you apply in body.
Overloads
2 ways to call compose().keyframeAnimator(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().keyframeAnimator<Value>({
initialValue: Value,
repeating?: boolean,
content: (value: any) => ViewModifierChain,
keyframes: KeyframeTracks,
})nonisolated func keyframeAnimator<Value>(
initialValue: Value,
repeating: Bool = true,
@ContentBuilder content: @escaping @Sendable (PlaceholderContentView<Self>, Value) -> some View,
@KeyframesBuilder<Value> keyframes: @escaping (Value) -> some Keyframes
) -> some ViewParameters
options.initialValue*ValueThe initial value that the keyframes will animate from.
options.repeatingbooleanWhether the keyframes are currently repeating. If false, the value at the beginning of the keyframe timeline will be provided to the content closure.
options.content*(value: any) => ViewModifierChainA content builder closure that takes two parameters. The first parameter is a proxy value representing the modified view. The second parameter is the interpolated value generated by the keyframes.
options.keyframes*KeyframeTracksKeyframes defining how the value changes over time. The current value of the animator is the single argument, which is equal to
initialValuewhen the view first appears, then is equal to the end value of the previous keyframe animation on subsequent calls.
Discussion
Note that the content closure will be updated on every frame while
animating, so avoid performing any expensive operations directly within
content.
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.
- 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.
- phaseAnimatorAnimates effects that you apply to a view over a sequence of phases that change continuously.
- 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.