Generic Function

withAnimation(_:_:)

Returns the result of recomputing the view’s body with the provided animation.

Declaration

func withAnimation<Result>(_ animation: Animation? = .default, _ body: () throws -> Result) rethrows -> Result

Discussion

This function sets the given Animation as the animation property of the thread’s current Transaction.

See Also

Animation

Animating Views and Transitions

When using SwiftUI, you can individually animate changes to views, or to a view’s state, no matter where the effects are. SwiftUI handles all the complexity of these combined, overlapping, and interruptible animations for you.

protocol Animatable

A type for animating views.

Beta
protocol AnimatableModifier

A modifier that can create another modifier with animation.

Beta
struct AnimatablePair

A pair of animatable values, which is itself animatable.

Beta
struct EmptyAnimatableData

An empty type for animatable data.

Beta
struct AnyTransition

A type-erased transition.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software