跳转至
Structure

PlainButtonStyle

A button effect that only modifies the label on interaction.

Declaration

struct PlainButtonStyle : PrimitiveButtonStyle

Overview

A button style that doesn't style or decorate its content while idle, but may apply a visual effect to indicate the pressed, focused, or enabled state of the button.

struct ExampleView: View {
    var body: some View {
        VStack {
            Button("Plain Banana🍌🍌") { tap() }
                .buttonStyle(PlainButtonStyle())
            Button("Borderless Banana 🍌🍌") { tap() }
                .buttonStyle(BorderlessButtonStyle())
            Button("Default Banana🍌🍌") { tap() }
                .buttonStyle(PlainButtonStyle())
        }
        .font(.title2)
    }

    func tap() { /\* implement here \*/ }
}
A view containing a VStack with three buttons; the first button is plain, the second is borderless, and the last is the default style.

To apply this style to a button, or to a view that contains buttons, use the buttonStyle(_:) modifier.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Instance Method

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


Initializer

init() Creates a plain button style.


Type Alias

Body A view that represents the body of a button.