Initializer

init(_:)

Creates a menu based on a style configuration.

Declaration 宣言

init(_ configuration: MenuStyleConfiguration)
Available when Label is MenuStyleConfiguration.Label and Content is MenuStyleConfiguration.Content.

Discussion 議論

Use this initializer within the makeBody(configuration:) method of a MenuStyle instance to create an instance of the menu being styled. This is useful for custom menu styles that modify the current menu style.

For example, the following code creates a new, custom style that adds a red border around the current menu style:


struct RedBorderMenuStyle: MenuStyle {
    func makeBody(configuration: Configuration) -> some View {
        Menu(configuration)
            .border(Color.red)
    }
}

See Also 参照

Creating a Menu from a Configuration