SwiftUI Tutorial: Working with ContextMenu

How to trigger a pop-up menu on a long press

Arc Sosangyo
Dev Genius
Published in
4 min readNov 14, 2023

--

Figure 1.

ContextMenu in SwiftUI functions as a view modifier, allowing the attachment of a contextual menu to a specific view. This menu appears as a pop-up, offering a collection of actions or options relevant to the selected view. Activating a context menu is accomplished through a touch-and-hold gesture or a force touch on…

--

--