Remember, you can simply disable the gesture recognizer in SwiftUI using a ternary operator.
@mikemikina1.2K followers
22,491 views
9 Comments
Comments from the original post on X (Twitter)

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

@harlanhaskins
.gesture(…) also has a variant that takes an isEnabled parameter.
3 likes

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

@rmenezes89
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.
1 like

@mikemikina
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.

@pavm035
Oh I didn’t know this, good one!
1 like

@wealthybaboon
Is this Swift for newbies?

@ConfusedVorlon
How is nil valid as "some Gesture" ??

@mikemikina
It's because Optional conditionally conforms to Gesture. You can read more about it here: