跳转至
Structure

PlainTextFieldStyle

A text field style with no decoration.

Declaration

struct PlainTextFieldStyle : TextFieldStyle

Overview

struct ExampleView: View {
    @State var myFruit: String = ""

    var body: some View {
        Text(myFruit)
        TextField("Fruit", text: $myFruit)
            .textFieldStyle(PlainTextFieldStyle())
            .padding()
    }
}
A gif displaying a text view in the center of the screen with a text field left aligned underneath it. The text field reads "Fruit" when no text is entered, and when the user types "Bananas" into the field, it appears in the text view above.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Initializer

init() Creates a plain text field style.