View ModifieriOS 13.0+macOS 10.15+tvOS 13.0+watchOS 6.0+
Overloads
2 ways to call compose().transition(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().transition(t: SwiftUI.AnyTransition)nonisolated func transition(_ t: AnyTransition) -> some ViewParameters
Discussion
When this view appears or disappears, the transition will be applied to it, allowing for animating it in and out.
The following code will conditionally show MyView, and when it appears or disappears, will use a slide transition to show it.
if isActive {
MyView()
.transition(.slide)
}
Button("Toggle") {
withAnimation {
isActive.toggle()
}
}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.
- 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.