Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Detect When a Button Is Currently Being Touched In SwiftUI
Copy link
Facebook
Email
Notes
More

Detect When a Button Is Currently Being Touched In SwiftUI

Daily Coding Tip 258

Type Safely's avatar
Type Safely
Mar 03, 2023
∙ Paid

Share this post

Type Safely
Type Safely
Detect When a Button Is Currently Being Touched In SwiftUI
Copy link
Facebook
Email
Notes
More
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More