Honey Honey - 2 months ago 11
Swift Question

How can I preselect a Caps lock for a specific textField?

When I begin to type, I want CapsLock to be preselected on the keyboard so I just type everything in Caps lock.


From Apple docs

The UITextInputTraits protocol defines features associated with keyboard input to a text object. For a custom text object to support keyboard input, it must adopt this protocol to interact properly with the text input management system. The UITextField and UITextView classes automatically support this protocol.

The auto-capitalization behavior of a text-based view. Used with the autocapitalizationType property.

enum UITextAutocapitalizationType : Int {
case None
case Words
case Sentences
case AllCharacters

You can achieve auto capitalisation of all characters by:

textField.autocapitalizationType = .allCharacters