Transition
protocol · iOS 17.0+ · SDK 27.1
@MainActor @preconcurrency protocol TransitionA description of view changes to apply when a view is added to and removed from the view hierarchy. A transition should generally be made by applying one or more modifiers to the `content`. For symmetric transitions, the `isIdentity` property on `phase` can be used to change the properties of modifiers. For asymmetric transitions, the phase itself can be used to change those properties. Transitions should not use any identity-affecting changes like `.id`, `if`, and `switch` on the `content`, since doing so would reset the state of the view they're applied to, causing wasted work and potentially surprising behavior when it appears and disappears. The following code defines a transition that can be used to change the opacity and rotation when a view appears and disappears. struct RotatingFadeTransition: Transition { func body(content: Content, phase: TransitionPhase) -> some View { content .opacity(phase.isIdentity ? 1.0 : 0.0) .rotationEffect(phase.rotation) } } extension TransitionPhase { fileprivate var rotation: Angle { switch self { case .willAppear: return .degrees(30) case .identity: return .zero case .didDisappear: return .degrees(-30) } } } A type conforming to this protocol inherits `@preconcurrency @MainActor` isolation from the protocol if the conformance is included in the type's base declaration: struct MyCustomType: Transition { // `@preconcurrency @MainActor` isolation by default } Isolation to the main actor is the default, but it's not required. Declare the conformance in an extension to opt out of main actor isolation: extension MyCustomType: Transition { // `nonisolated` by default } - See Also: `TransitionPhase` - See Also: `AnyTransition`
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
17 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
Transition.offset(_:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.offset(x:y:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.move(edge:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.opacity
Static protocol requirements cannot be called through an instance.
Transition.slide
Static protocol requirements cannot be called through an instance.
Transition.push(from:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.symbolEffect(_:options:)
This declaration needs Swift generic type arguments. (no canonical witness for T)
Transition.symbolEffect
Static protocol requirements cannot be called through an instance.
Transition.animation(_:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.combined(with:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.properties
Static protocol requirements cannot be called through an instance.
Transition.apply(content:phase:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.identity
Static protocol requirements cannot be called through an instance.
Transition.blurReplace(_:)
This protocol needs associated types that cannot yet cross the bridge.
Transition.blurReplace
Static protocol requirements cannot be called through an instance.
Transition.scale
Static protocol requirements cannot be called through an instance.
Transition.scale(_:anchor:)
This protocol needs associated types that cannot yet cross the bridge.