Search code examples
iosswiftswiftuikeyboard

SwiftUI Keyboard Word Suggestion Bar


How do I remove the word suggestion bar on the keyboard? I tried .disableAutocorrection(true) but it doesn't seem to actually hide it as shown in the image. If I use a secureField, then obviously, it will hide it, but how can I do that with a regular textfield?

enter image description here


Solution

  • Set your TextField up this way:

            TextField("Enter some text...", text: $someText)
                .keyboardType(.alphabet)
                .disableAutocorrection(true)
    

    Just .disableAutocorrection(true) leaves the remnants of the suggestion bar, but adding the .keyboardType(.alphabet) makes it all go away.