Get your own website
Demo.swift
ContentView.swift
App.swift
 
import SwiftUI

struct RotationAccumDemo: View {
  @State private var total: Angle = .zero
  @State private var current: Angle = .zero
  var body: some View {
    VStack(spacing: 12) {
      Image(systemName: "arrow.triangle.2.circlepath")
        .font(.system(size: 48))
        .rotationEffect(total + current)
        .gesture(
          RotationGesture()
            .onChanged { value in current = value }
            .onEnded { value in total += value; current = .zero }
        )
      Text("Angle: \(Int((total + current).degrees))°")
    }
    .padding()
  }
}

                    
import SwiftUI

struct ContentView: View {
  var body: some View { RotationAccumDemo() }
}

                    
import SwiftUI

@main
struct MyApp: App {
  var body: some Scene {
    WindowGroup { ContentView() }
  }
}