How to make two gestures recognize at the same time using simultaneousGesture() - a free SwiftUI by Example tutorial
By default SwiftUI will trigger only one gesture recognizer action at a time, which is usually whichever one is the front-most view in your hierarchy – it would prefer a recognizer on a child view rather than its parent, for example. If you want to override this behavior to make two gestures trigger at once, you should use the simultaneousGesture() when creating your second and subsequent gestures. For example, in this code we have two tap gestures, but SwiftUI will execute only the one attached to the circle because it’s the child of the VStack: Download this as an Xcode project If you want both gestures to trigger – i.e., if you want both “Circle tapped” and “VStack tapped” to be printed – you should use simultaneousGesture() on the VStack like this: Download this as an Xcode project Note: You should use simultaneousGesture() with the gesture that would otherwise not be executed otherwise it won’t work. So, in our previous example using simultaneousGesture() with the circle and a s
How to make two gestures recognize at the same time using simultaneousGesture() - a free SwiftUI by Example tutorial WWDC26: Save 50% on my books and bundles! >> < How to force one gesture to recognize before another using highPriorityGesture() How to create gesture chains using sequenced(before:) > How to make two gestures recognize at the same time using simultaneousGesture() Paul Hudson @twostraws May 12th 2022 Updated for Xcode 16.4 By default SwiftUI will trigger only one gesture recognizer action at a time, which is usually whichever one is the front-most view in your hierarchy – it woul
related reading
- SwiftUI by Example - free quick start tutorials for Swift developershackingwithswift.com
- Frequently asked questions about SwiftUI - a free SwiftUI by Example tutorialhackingwithswift.com
- How to Take Screenshots of Views in SwiftUItnvmadhav.me
- Building a menu using List - a free SwiftUI by Example tutorialhackingwithswift.com
- Alignment - SwiftUI Field Guideswiftuifieldguide.com
- Answering the big question: should you learn SwiftUI, UIKit, or both? - a free SwiftUI by Example tutorialhackingwithswift.com
- Designing Fluid Interfaces - WWDC18 - Videos - Apple Developerdeveloper.apple.com
- Composing views to create a list row - a free SwiftUI by Example tutorialhackingwithswift.com
- What is SwiftUI? - a free SwiftUI by Example tutorialhackingwithswift.com
- A Day in the Life of a SwiftUI View — Chris Eidhofchris.eidhof.nl
- Behind the scenes of UI: Part 2 - SwiftUIvbat.dev
- Displaying a detail screen with NavigationLink - a free SwiftUI by Example tutorialhackingwithswift.com