Type Safely

Type Safely

Detect When a Button Is Currently Being Touched In SwiftUI

Daily Coding Tip 258

Type Safely's avatar
Type Safely
Mar 03, 2023
∙ Paid
Photo by Katie Lyke on Unsplash

A long press gesture has an .onChanged() event that happens when a touch of any duration begins.

Then there is an .onEnded() event when the press has been held for the stated minimum duration (0.5 seconds by default).

Finally there is an .updating(_:) event which occurs before .onChanged(), and that’s what I’ll be using to…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2025 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture