SwiftUI TextField force lowercase

TextField has a .autocapitalization() method.

You can use like this without custom binding:

TextField("URL", text: $url)
                    .keyboardType(.URL)
                    .autocapitalization(.none)

For iOS 15 SwiftUI have a new .textInputAutocapitalization() method:

.textInputAutocapitalization(.never)

This means that any text input by the user will be .lowercased()

Leave a Comment