跳转至
Structure

BorderlessButtonMenuStyle

A menu style that displays a borderless button that toggles the display of the menu's contents when pressed.

Declaration

struct BorderlessButtonMenuStyle : MenuStyle

Overview

On macOS, the button optionally displays an arrow indicating that it presents a menu.

Pressing and then dragging into the contents triggers the chosen action on release.

For example:

struct BorderlessButtonMenuView: View {
    var body: some View {
        Menu("PDF") {
            Button("Open in Preview", action: { })
            Button("Save as PDF", action: { })
        }
        .menuStyle(BorderlessButtonMenuStyle())
    }
}
A gif displaying a view containing a borderless button style menu "PDF" that once clicked displays two buttons, "Open in Preview" and "Save as PDF", each with no action attached.

Availability

iOS 14.0+

macOS 11.0+

Topics


Instance Method

makeBody(configuration:) Creates a view that represents the body of a menu.


Type Alias

Body A view that represents the body of a menu.


Initializer

init() Creates a borderless button menu style.