Is it possible to replace every whitespace that is created by pressing the spacebar with another character, which in this case is an underscore, while the user is typing in the text field?
I found something about
.replacingOccurrences(of: "", with: "_")
but don't know how to apply it in real-time while typing is occurring.
Here is the text field I am using with a simple state variable:
TextField("Enter a username", text: $txt)
.padding()
.disableAutocorrection(true)
.autocapitalization(.none)