跳转至
Structure

RoundedBorderTextFieldStyle

A text field style with a system-defined rounded border.

Declaration

struct RoundedBorderTextFieldStyle : TextFieldStyle

Overview

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

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

    var body: some View {
        Text(myFruit)
        TextField("Fruit", text: $myFruit)
            .textFieldStyle(RoundedBorderTextFieldStyle())
            .padding()
    }
}
A gif displaying a view with a rounded border TextField with the placeholder "Fruit" and padding; as the text field is populated by text, the text is stored in a state variable that is simultaneously displayed in the text line above the input box.

Availability

iOS 13.0+

macOS 10.15+

Topics


Initializer

init() Creates a rounded border text field style.