跳转至
Structure

RotationGesture

A gesture that recognizes a rotation motion and tracks the angle of the rotation.

Declaration

struct RotationGesture : Gesture

Overview

A rotation gesture tracks how a rotation event sequence changes. To recognize a rotation gesture on a view, create and configure the gesture, and then add it to the view using the gesture(_:including:) modifier.

Add a rotation gesture to a Rectangle and apply a rotation effect:

RotationGesture Example 1

struct RotationGestureView: View {
    @State var angle = Angle(degrees: 0.0)

    var rotation: some Gesture {
        RotationGesture()
            .onChanged { angle in
                self.angle = angle
            }
    }

    var body: some View {
        Rectangle()
            .frame(width: 200, height: 200, alignment: .center)
            .rotationEffect(self.angle)
            .gesture(rotation)
    }
}

Availability

iOS 13.0+

macOS 10.15+

Topics


Instance Property

minimumAngleDelta The minimum delta required before the gesture succeeds.


Initializer

init(minimumAngleDelta:) Creates a rotation gesture with a minimum delta for the gesture to start.


Type Alias

Body The type of gesture representing the body of Self.

Value The type representing the gesture's value.