> For the complete documentation index, see [llms.txt](https://eneskaraosman53.gitbook.io/swiftui/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eneskaraosman53.gitbook.io/swiftui/gestures/rotation-gesture.md).

# RotationGesture

Rotation Gesture is applicable to any view

**Usage**

```swift
@State var rotationAngle: Angle = .degrees(0)
@State var currentAngle: Angle = .degrees(0)

var body: some View {
        
    Rectangle()
        .rotation(currentAngle + rotationAngle)
        .foregroundColor(.orange)
        .frame(height: 50)
        .padding()
        .gesture(
            RotationGesture()
                .onChanged { angle in
                    self.rotationAngle = angle
                }
                .onEnded { angle in
                    // To keep the latest state.
                    self.rotationAngle += self.currentAngle
                    self.currentAngle = .degrees(0)
                }
        )
     
}
```

Result for sample code is below.

![rotation-gesture-demo](https://1761232408-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5Upqg27mOVmaED1CFL%2F-M5g-yAm8ooiF2o6-6xL%2F-M5gVija7KslHjE82jte%2FrotationGesture.gif?alt=media\&token=3815afc2-f443-4e4e-9819-8a657f867929)
