Last active
November 23, 2019 14:49
-
-
Save a-v-ershov/f21c9ec6b2fc8bfe1d88d523155eb839 to your computer and use it in GitHub Desktop.
Пример RotationGesture
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 | |
let rotationGesture = RotationGesture() | |
// Изменяем угол наклона прямоугольника | |
.onChanged { value in | |
self.rectangleRotationAngle = value | |
} | |
return Rectangle() | |
.foregroundColor(.green) | |
.cornerRadius(40) | |
// Вращаем прямоугольник | |
.rotationEffect(rectangleRotationAngle) | |
.frame(width: 200, height: 100, alignment: .center) | |
// Добавляем gesture к view | |
.gesture(rotationGesture) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment