← back to the blog


How to uppercase text SwiftUI TextField

Posted on December 16th, 2019 in Swift by George
struct ContentView: View {
    
    @State private var textState: String = "";

    var body: some View {
        ZStack {
            Image("bgimage") // this is background image
            VStack {
                TextField("TEXT", text: $textState)
                    .foregroundColor(Color.black)
                    .textFieldStyle(RoundedBorderTextFieldStyle())
                    .padding()
                    .autocapitalization(UITextAutocapitalizationType.allCharacters) //**! HERE !**

            }
        }
    }
}

 

Thank you!