Skip to content

Instantly share code, notes, and snippets.

@tanmayb123
Created June 16, 2019 19:04
Show Gist options
  • Select an option

  • Save tanmayb123/c4e16324b09b4c416088c2e1cb76c5e4 to your computer and use it in GitHub Desktop.

Select an option

Save tanmayb123/c4e16324b09b4c416088c2e1cb76c5e4 to your computer and use it in GitHub Desktop.
struct ContentView : View {
@State var stackLocation: CGPoint = .zero
@State var stackAngle: Angle = .zero
var body: some View {
VStack(alignment: .leading) {
Text("Hello World")
.font(.largeTitle)
.bold()
Text("This is my test app.")
}
.offset(x: stackLocation.x, y: stackLocation.y)
.rotationEffect(stackAngle)
.gesture(DragGesture()
.onChanged {
self.stackLocation = $0.location
}
.onEnded { _ in
self.stackLocation = .zero
}
)
.animation(.spring())
.gesture(RotationGesture()
.onChanged {
self.stackAngle = $0
}
.onEnded { _ in
self.stackAngle = .zero
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment