Created
November 23, 2019 17:22
-
-
Save a-v-ershov/6c0c392195ab55f7e703000df17c9d84 to your computer and use it in GitHub Desktop.
RotationGesture example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RotationGestureExample: View { | |
@State var rectangleRotationAngle: Angle = .zero | |
var body: some View { | |
// DragGesture creation | |
let rotationGesture = RotationGesture() | |
// Rotation angle recalculation for the rectangle | |
.onChanged { value in | |
self.rectangleRotationAngle = value | |
} | |
return Rectangle() | |
.foregroundColor(.green) | |
.cornerRadius(40) | |
// Rotate the rectangle | |
.rotationEffect(rectangleRotationAngle) | |
.frame(width: 200, height: 100, alignment: .center) | |
// Add the rotationGesture to this view | |
.gesture(rotationGesture) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment