How to use RotationGesture in SwiftUI | Continued Learning #3
rotationEffect(currentAngle)
.gesture(
RotationGesture()
.onChanged({ value in
currentAngle = value
})
.onEnded({ value in
currentAngle = Angle(degrees: 0)
})
)
import SwiftUI
struct RotationGestureBootCamp: View {
@State private var currentAngle: Angle = Angle(degrees: 0)
var body: some View {
Text("Hello, World!")
.font(.largeTitle)
.fontWeight(.semibold)
.padding(50)
.background(Color.blue.cornerRadius(10))
.rotationEffect(currentAngle)
.gesture(
RotationGesture()
.onChanged({ value in
currentAngle = value
})
.onEnded({ value in
currentAngle = Angle(degrees: 0)
})
)
}
}
회전 효과를 위해 값을 받아야 하는 각(
Angle
)은degrees
,radians
를 파라미터로 이니셜라이즈된다.