swiftuimenu

SwiftUI popover menu from a button


I couldn't find any example to reproduce the following UI part (example taken from XCode):

enter image description here

A + button (this I found many - this is a Gradient Button) at the bottom of a list (also many examples) that, when left-clicked, popovers a menu with any arrow.

I found example for buttons that show a popover, but there is always an arrow. And using Menu (on macOS) actually shows a menu (with an arrow).


Solution

  • To hide the arrow produced by Menu, simply use a plain (or your own custom) button style.

    struct ContentView: View {
        var body: some View {
            Menu {
                Button("One") {}
                Button("Two") {}
                Button("Three") {}
            } label: {
                Image(systemName: "plus")
            }
            .buttonStyle(.plain)
        }
    }
    

    produces

    enter image description here