Search code examples
iosswiftswiftuipopupcontextmenu

SwiftUI Custom View For Context Menu


I want to implement same custom popup view when press long press gesture on a view as shown in the photo (from Tweeter App), so I can show a custom view and context menu at same time.

enter image description here


Solution

  • There is a new method in iOS 16 SDK (currently in beta) that allows for showing a preview directly from SwiftUI without the need of tapping into the UIKit.

    contextMenu(menuItems:preview:)