Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swiftui textfield focus

struct ContentView: View {
    enum Field: Hashable {
        case name
        case fullName
    }
    @FocusState private var focusedField: Field?

    var body: some View {
        TextField("Full Name", ...)
            .focused($focusedField, equals: .name)
            .focused($focusedField, equals: .fullName)
    }
}
Source by developer.apple.com #
 
PREVIOUS NEXT
Tagged: #swiftui #textfield #focus
ADD COMMENT
Topic
Name
9+4 =