Context Menu allows you to create extra features specific to some views like images in a gallery or messages. With Context Menu in SwiftUI, you can add the option to share an image or remove messages.
Let’s say you have some Text view.
To add Context Menu to it there is .contextMenu view modifier. It’s special because each view inside it represents a separate button.
Let’s use Text and Image as examples.
You’ll notice that there are two buttons and it doesn’t look well. Instead of two separate views use one button.
Now it looks much better and you can add some action code inside the button.