Structure¶
MenuStyleConfiguration¶
A configuration of a menu.¶
Declaration¶
struct MenuStyleConfiguration
Overview¶
Use this type in makeBody(configuration:) to create your own custom MenuStyle. The parameter passed to makeBody(configuration:) is of type MenuStyleConfiguration.
For example, the following code creates a new, custom style that adds a red border to the current menu style:
struct RedBorderMenuStyle : MenuStyle {
func makeBody(configuration: MenuStyleConfiguration) -> some View {
Menu(configuration)
.border(Color.red)
}
}
strut ContentView: View {
var body: some View {
Menu {
Button("Open in Preview", action: { })
Button("Save as PDF", action: { })
} label: {
Image(systemName: "doc")
Text("PDF")
}
.menuStyle(RedBorderMenuStyle())
}
}
Availability¶
iOS 14.0+
macOS 11.0+
Topics¶
Structure¶
Content A type-erased content of a menu.
Label A type-erased label of a menu.