Using Context Menu with Previews in SwiftUI
SwiftUI’s contextMenu modifier is a simple API that does a lot for us. I wrote about building context menus in both UIKit and SwiftUI recently. I did not go into detail about support for the custom previews that landed in iOS 16, iPadOS 16 and macOS 13. Let us fill that gap. Recap: Context menus in SwiftUI A context menu is equivalent of a right-click on touch devices. Using long‑press (or Control‑click on the Mac) on a view reveals a menu of options exactly where the user needs it. In pure SwiftUI we use .contextMenu to create these menus: ...