withAnimation

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

FunctioniOS 13.0+

Overloads

2 ways to call withAnimation(). Each is one SwiftUI overload, picked by the arguments you pass.

React
function withAnimation<Result>(body: () => Result): Result

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

Parameters

See also

More in SwiftUI functions.