Skip to content

Instantly share code, notes, and snippets.

@ershovio
Last active November 23, 2019 14:49
Show Gist options
  • Save ershovio/f21c9ec6b2fc8bfe1d88d523155eb839 to your computer and use it in GitHub Desktop.
Save ershovio/f21c9ec6b2fc8bfe1d88d523155eb839 to your computer and use it in GitHub Desktop.
Пример RotationGesture
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