How to disable Autocorrection for TextField in SwiftUI?

SwiftUI TextField – Disable Autocorrection

To disable Autocorrection for TextField, call disableAutocorrection() method on this TextField, and pass true as argument to disableAutocorrection() method.

Example

In the following example, we will disable autocorrection for TextField.

ContentView.swift

import SwiftUI

struct ContentView: View {
    @State private var username: String = ""
    
    var body: some View {
        TextField(
            "Enter...",
            text: $username
        )
        .disableAutocorrection(true)
        .autocapitalization(.none)
        .padding(.all)
        .border(Color(UIColor.separator))
        .padding(.all)
    }
}

Screenshot

Summary

Summarising this SwiftUI Tutorial, we learned how disable Autocorrection for TextField control.