Honey Honey - 1 year ago 87
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download