Loading video...
Video Failed to Load
Remember, you can simply disable the gesture recognizer in SwiftUI using a ternary operator. You may need to refactor your gesture recognizer, but it’s quite simple ➡️
22,444 views • 1 year ago •via X (Twitter)
9 Comments

A follow up! It turns out that the documentation includes gesture(_:isEnabled:), so you can simply pass a boolean value there. Kudos to @harlanhaskins!

.gesture(…) also has a variant that takes an isEnabled parameter.

Wait, what?! How did I miss it? I swear I was looking for it in the documentation the other day 😄 Thanks for sharing! 🙌

You can achieve the same result by using `.disabled(!isActive)` so you don’t need to touch your gestures and keep your code as simple as it can be.

In this example, it will certainly work the same way. However, if you have another gesture recognizer or the view has additional interactions, it will not work.

Oh I didn’t know this, good one!

Is this Swift for newbies?

How is nil valid as "some Gesture" ??

It's because Optional conditionally conforms to Gesture. You can read more about it here:
Related Videos
A simple note says it all, and netizens are loving the gesture.
Malay Mail
60,374 views • 5 months ago

