Posts

Post not yet marked as solved
1 Replies
55 Views
Apple’s developer documentation (https://developer.apple.com/documentation/swiftui/gesture) states that it is possible to “Create custom gestures by declaring types that conform to the Gesture protocol.” However, I cannot find an example of this anywhere on the internet. Does anyone have an example of a custom Gesture? Where would an app obtain touch data to begin with?
Posted Last updated
.
Post marked as solved
2 Replies
93 Views
How do I access the value in Settings → Accessibility → Double-tap Timeout? More details: I'm making a game with a SpriteView in SwiftUI that needs to react immediate to a touch while also detecting and responding to double, triple, and quadruple taps. To do this, I have the following: var touch: some Gesture {     var lastTouchTime = Date.now     var tapCounter = 1     return DragGesture(minimumDistance: 0, coordinateSpace: .local)         .onChanged() { touch in             // Respond immediately to touch.         }         .onEnded() { touch in             if lastTouchTime.timeIntervalSinceNow > -0.25 {                 tapCounter += 1             } else {                 tapCounter = 1             }             switch tapCounter {             case 1:                 break             case 2:                 // Respond to double-tap.             case 3:                 // Respond to triple-tap.             default:                 // Respond to quadruple tap.                 // Quintuple, sextuple, etc. taps also resolve here, which is fine.             }             lastTouchTime = Date.now         } } I would like to substitute 0.25 with the user's value in Accessibility settings, but I do not know how to access this value. The following does not work: .gesture(doubleTap) .gesture(singleTap) SwiftUI waits for the double-tap to fail before reacting to the single tap, which is not what I need, plus stacking triple and quadruple taps on top of this just fails.
Posted Last updated
.