Created
January 28, 2022 15:22
-
-
Save pitt500/f6a96a70cdf238c4b50171aceafd45b2 to your computer and use it in GitHub Desktop.
Tap Gesture demo. Check out all the details here: https://youtu.be/90NcdAV0gPg
This file contains 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
import SwiftUI | |
struct ContentView: View { | |
@GestureState var anotherState = false | |
@State var isTapped = false | |
var tap: some Gesture { | |
TapGesture(count: 4) | |
.onEnded { state in | |
// State is an empty tuple (void) | |
isTapped.toggle() | |
} | |
.updating( | |
self.$anotherState | |
) { currentState, pastState, transaction in | |
// useless, it just report an empty tuple | |
} | |
} | |
var body: some View { | |
Circle() | |
.fill(isTapped ? .red : .blue) | |
.frame(width: 200, height: 200) | |
// .onTapGesture(count: 4) { | |
// isTapped.toggle() | |
// } | |
.gesture(tap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment