Created
June 16, 2019 19:04
-
-
Save tanmayb123/c4e16324b09b4c416088c2e1cb76c5e4 to your computer and use it in GitHub Desktop.
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 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