I experimenting with the SwiftUI TextField and want to get rid of the predictive suggestion bar above the keyboard:
struct ContentView: View {
@State private var text: String = ""
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
TextField("Hello", text: $text)
.autocorrectionDisabled()
.textContentType(.init(rawValue: ""))
}
.padding()
}
}
When typing, the predictive suggestions are still shown above the keyboard. Is there a way to get rid of these as well?

You need to use autocorrectionDisabled instead of disableAutocorrection, add .textContentType(.init(rawValue: "")) and don't forget to set the keyboard to .keyboardType(.asciiCapable). Default keyboard doesn't work. I don't know why.
struct ContentView: View {
@State private var text: String = ""
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
TextField("Hello", text: $text)
.keyboardType(.asciiCapable)
.autocorrectionDisabled(true)
.textContentType(.init(rawValue: ""))
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With