On Tap Gesture

A gesture that recognizes one or more taps.

Updated over a week ago

The On Tap Gesture is used specifically for responding to tap events. Unlike a Button, the On Tap Gesture doesn’t have the dim effect when you tap which is useful for when you want to be able to click an entire screen rather than just a Button to move forward in a Navigation Stack.

In this example, to ensure the On Tap Gesture modifier gets applied to the entire screen, it was added to the ZStack which houses the VStack with the Text layers, and the purple Rectangle acting as the background. The Rectangle was turned into a Navigation Link to specify the destination screen upon tap.

The On Tap Gesture is also bound to the isNextScreenActive Boolean property, which defaults to False, but upon tap, is set to True.

You can also specify it’s Count parameter, or the required number of taps to complete a tap gesture. For instance, you can set the Count to 2 so that the user has to double tap the image to like it.

Similar to a Button, you can add an action that executes upon tapping. Click on the plus (+) icon in the Actions section and click on “Dismiss” to select one of the following Actions:

  • Dismiss - Dismiss a modal presentation, like a Sheet or a popover, or pop the current layer from a Navigation Stack

  • Open URL - Open a specific URL

  • Refresh - Initiate a refresh operation nested within a Data Source

  • Set - Set a component property to a specific value

  • Toggle - Toggle a Boolean property between True and False

  • Increment - Increment a Number property by a specific amount

  • Decrement - Decrement a Number property by a specific amount

  • Custom - Custom actions are used with the Judo SDK in an Xcode project to run custom code

Did this answer your question?