Animations

Create smooth transitions from one state to another.

Overview 概要

You tell SwiftUI how to draw your app’s user interface for different states, and then rely on SwiftUI to make interface updates when the state changes. To avoid abrupt visual transitions when the state changes, add animation in one of the following ways:

  • Animate all of the visual changes for a state change by changing the state inside a call to the withAnimation(_:_:) global function.

  • Add animations to particular views when specific values change by applying the animation(_:value:) view modifier.

  • Animate changes to a Binding by using the binding’s animation(_:) method.

SwiftUI animates the effects produced by many built-in view modifiers, like those that set a scale or opacity value. You can animate other values by making your custom views or view modifiers conform to the Animatable protocol and telling SwiftUI about the value you want to animate.

When an animated state change results in adding or removing a view to or from the view hierarchy, you can tell SwiftUI how to transition the view into or out of place using built-in transitions defined by AnyTransition, like slide or scale. You can also create custom transitions.

Topics 話題

Animation アニメーション

Animatable Data

Transitions

Transactions

Deprecated Types

See Also 参照

Interactivity