Here’s a sample README for your project based on your description:
This repository demonstrates an experimental SwiftUI implementation of context menus with previews.
It showcases how to leverage the contextMenu
modifier in SwiftUI to present rich, interactive previews when users long-press or right-click on UI elements.
Video | Normal | Context Menu |
---|---|---|
![]() |
![]() |
- SwiftUI-based: Pure SwiftUI experiment, no UIKit required.
- Context Menus: Easily attach context menus to views.
- Preview Support: Show previews alongside menu actions.
- Customizable Actions: Add, remove, or modify menu options as needed.
-
Clone the repository
git clone https://github.com/edwinbosire/swiftui-context-menu-preview.git
-
Open in Xcode
Open the.xcodeproj
or.xcworkspace
file in Xcode. -
Run the Project
Select a simulator or device and hit Run.
Check out the sample views in the project for examples of how to use the contextMenu
modifier with previews:
YourView()
.contextMenu {
Button("Action 1", action: { /* ... */ })
Button("Action 2", action: { /* ... */ })
} preview: {
PreviewView()
}
MIT License. See LICENSE for details.
Let me know if you want to add installation instructions, credits, or more details!