How to disable autocorrect in a TextField
About 2 min
How to disable autocorrect in a TextField 관련
SwiftUI by Example
Back to Home
How to disable autocorrect in a TextField | SwiftUI by Example
How to disable autocorrect in a TextField
Updated for Xcode 15
SwiftUI's TextField
enables autocorrect by default, which is what you'll want in most cases. However, if you want to disable it you can do so by using the disableAutocorrection()
modifier, like this:
struct ContentView: View {
@State private var name = ""
var body: some View {
TextField("Enter your name", text: $name)
.disableAutocorrection(true)
}
}
Tips
In earlier Xcode releases, the icon for disabling autocorrect is a duck with a line through it. I'll let you figure out why for yourself…
Similar solutions…
How to disable taps for a view using allowsHitTesting() | SwiftUI by Example
How to disable taps for a view using allowsHitTesting()
How to disable the overlay color for images inside Button and NavigationLink | SwiftUI by Example
How to disable the overlay color for images inside Button and NavigationLink
How to disable ScrollView clipping so contents overflow | SwiftUI by Example
How to disable ScrollView clipping so contents overflow
How to make a TextField expand vertically as the user types | SwiftUI by Example
How to make a TextField expand vertically as the user types
How to dismiss the keyboard for a TextField | SwiftUI by Example
How to dismiss the keyboard for a TextField