Skip to content

Instantly share code, notes, and snippets.

@pitt500
Created January 28, 2022 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pitt500/f6a96a70cdf238c4b50171aceafd45b2 to your computer and use it in GitHub Desktop.
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
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