跳转至
Structure

DefaultTextFieldStyle

The default text field style.

Declaration

struct DefaultTextFieldStyle : TextFieldStyle

Overview

TextField can be styled with the textFieldStyle(_:) modifier.

The Default TextField Style is Plain on iOS.

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

    var body: some View {
        Text(myFruit)
        TextField("Fruit", text: $myFruit)
            .textFieldStyle(DefaultTextFieldStyle())
            .padding()
    }
}
A gif showing a view with a VStack containing an iOS default style textfield that once populated displays the corresponding text in a text item.

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Initializer

init() Creates a default text field style.