RotateGesture
A gesture that recognizes a rotation motion and tracks the angle of the rotation.
Declaration
type RotateGesture = { minimumAngleDelta?: Angle; } | { minimumAngleDelta?: Angle; inputKinds?: GestureInputKinds; };nonisolated struct RotateGestureType methods
Overview
A rotate gesture tracks how a rotation event sequence changes. To
recognize a rotate gesture on a view, create and configure the gesture,
and then add it to the view using the View.gesture(_:including:)
modifier.
Add a rotate gesture to a Rectangle and apply a rotation effect:
struct RotateGestureView: View {
@State private var angle = Angle(degrees: 0.0)
var rotation: some Gesture {
RotateGesture()
.onChanged { value in
angle = value.rotation
}
}
var body: some View {
Rectangle()
.frame(width: 200, height: 200, alignment: .center)
.rotationEffect(angle)
.gesture(rotation)
}
}From Apple’s SwiftUI documentation. Code samples there are Swift.
See also
More in Gestures and input.
- AutomaticHoverEffectThe default hover effect based on the surrounding context.
- CustomHoverEffectA type that represents how a view should change when a pointer hovers over a view, or when someone looks at the view.
- DragConfigurationThe behavior of the drag, proposed by the dragging source. A value that describes the drag operations a drag source supports.
- DragConfigurationOperationsOutsideAppDescribes the suggested drag operations to other applications.
- DragConfigurationOperationsWithinAppDescribes the drag operations suggested to destinations within the app.
- DragGestureA dragging motion that invokes an action as the drag-event sequence changes.
- DragGestureValueThe attributes of a drag gesture.
- DragSessionDescribes the ongoing dragging session.
- DragSessionIDThe identifier of a drag session.
- DragSessionPhaseThe phase of the current drag session
- GestureAn instance that matches a sequence of events to a gesture, and returns a stream of values for each of its states.
- GestureChainGesture with chained calls: SwiftUI.Gesture.exclusively(...).