Autocapitalization is an iOS mechanism that automatically converts the first letter of entered text to uppercase in certain contexts. UIKit provides the autocapitalizationType property in the UITextInputTraits protocol with four modes: none, words, sentences and allCharacters. According to the Apple Text Programming Guide (2025), proper configuration of autocapitalization improves user experience and reduces the number of manual corrections during input. Use the sentences mode for most text fields and none for usernames and passwords.
Key Takeaways
Autocapitalization is an iOS operating system feature that automatically converts the first character of text to uppercase when certain conditions are met. The mechanism is controlled through the autocapitalizationType property, available for all elements implementing the UITextInputTraits protocol: UITextField, UITextView and UISearchBar.
The feature operates at the iOS text engine level and activates at the moment each character is entered. The system analyzes the cursor position and surrounding text to determine whether to capitalize the current input character. If the condition is met, iOS automatically replaces the lowercase letter with an uppercase one before it appears in the field.
According to the Apple Human Interface Guidelines (2025), autocapitalization is part of a broader predictive input system that also includes autocorrection and predictive text input. Users can disable all these features globally in system settings (Settings > General > Keyboard), but developers also control them at the individual field level.
Unlike autocorrection, autocapitalization does not use a language model — it works by simple rules: after a period and space, at the beginning of text, after a newline character. The exception is the words mode, where the first letter of each word is capitalized regardless of context.
UITextAutocapitalizationType is an enumeration of four values that define the automatic case conversion strategy. Each mode is designed for a specific type of text field and solves a particular user experience task.
The .none mode completely disables automatic case conversion. All characters are entered in the case the user types them. This mode is required for password fields, email addresses, nicknames, search queries, and any fields where case matters for server-side data processing.
The .words mode capitalizes the first letter of each entered word. The system determines word boundaries by spaces and converts the first character after a space to uppercase. This mode is convenient for first name, last name, city names, street names, and other fields where each word should start with a capital letter.
The .sentences mode is the most common and is used by default for most text fields. The system capitalizes the first letter after a period, exclamation mark, or question mark followed by a space. This mode is ideal for notes, messages, comments, and other multi-line text fields.
The .allCharacters mode converts all entered characters to uppercase. This mode is equivalent to constantly holding Caps Lock and is used for fields where data must be in uppercase: postal codes, country codes, abbreviations, order numbers. Use with caution, as uppercase text is harder to read.
| Mode | Description | Input Example | Recommendation |
|---|---|---|---|
| .none | No changes | john@mail.com | Email, passwords, search |
| .words | Each word | John Smith | Name, address, city |
| .sentences | Sentence start | Hello. How are you? | Messages, notes |
| .allCharacters | All uppercase | ABC-123 | Codes, indexes |
The autocapitalization mechanism activates during key press processing, before the character is displayed on screen. When the user presses a key, UITextInputTraits checks the current cursor position and applies the case conversion rule according to the set autocapitalizationType.
For .sentences mode, the system tracks trigger characters: period (.), exclamation mark (!), question mark (?), and newline character ( ) when enabled. After detecting a trigger character and the following space, the system sets a “capital letter expected” flag for the next input character.
The .words mode tracks the space character as a trigger. After each space, the system expects a capital letter for the next word. However, there are exceptions: after a hyphen, apostrophe, and other punctuation marks within a word, a capital letter is not inserted. For example, “O’Brien” will remain correct.
An important feature is that autocapitalization works only on the first character of a word. If the user enters a word containing uppercase letters in the middle (e.g., iPhone or macOS), the system does not change them, since the conversion applies only to the first character after the trigger. This means brand names and products with non-standard capitalization will not be affected.
Autocapitalization should be disabled in fields where character case matters for correct data processing. Common cases: email address fields, nicknames and usernames, passwords, search queries, URLs, confirmation codes, IMEI and serial numbers. In all these cases, automatic case changes will lead to errors during server-side processing.
For search fields (UISearchBar), autocapitalization is disabled by default, which matches user expectations. A search query can be entered in any case, and the server usually converts it to lowercase on its own. If autocapitalization is enabled for search, the user will have to manually correct the capital letter at the beginning of each query.
In registration forms, the username or nickname field should have .none mode, as many systems differentiate case in usernames. The email field should also be without autocapitalization — although domain names are not case-sensitive, the local part of email theoretically can be case-sensitive, though in practice this is rare.
According to Apple Developer Documentation, fields with secureTextEntry (passwords) automatically inherit autocapitalizationType = .none, even if the developer explicitly set a different value. The system has the highest priority for secure input and ignores any attempts to enable autocapitalization for a password field.
Configuring autocapitalization in Swift is done through the autocapitalizationType property. The property is available for UITextField, UITextView and UISearchBar. The value can be set both in code and through Interface Builder in the attributes inspector, where the mode is called Capitalization.
let nameField = UITextField()
nameField.autocapitalizationType = .words
let emailField = UITextField()
emailField.autocapitalizationType = .none
For a contact form, configure each field according to its semantics: name — .words, email — .none, message — .sentences. This combination provides the best user experience and minimizes the need for manual case correction.
class ContactFormViewController: UIViewController {
@IBOutlet var nameField: UITextField!
@IBOutlet var emailField: UITextField!
@IBOutlet var messageView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
nameField.autocapitalizationType = .words
emailField.autocapitalizationType = .none
messageView.autocapitalizationType = .sentences
}
}
For programmatic mode changes at runtime, use the UITextFieldDelegate delegate. For example, if a field can be used in different contexts, change autocapitalizationType in the textFieldDidBeginEditing method depending on the current form operation mode.
func textFieldDidBeginEditing(_ textField: UITextField) {
if textField === codeField {
textField.autocapitalizationType = .allCharacters
}
}
Autocapitalization depends on the input language set on the user’s keyboard. Different languages may have different case conversion rules. For example, in Turkish, the letter “i” in uppercase becomes “İ” (with dot), while “I” in lowercase becomes “ı” (without dot). iOS handles these features automatically.
For Russian, autocapitalization follows the same rules as English: capital letter after a period, at the beginning of a sentence, and after a newline. Issues may arise with the letter “yo” — although it is present in the system dictionary, not all keyboard layouts display it on the main layer, and autocapitalization correctly converts “yo” to “Yo”.
For Chinese, Japanese, and Korean, autocapitalization does not apply, as these languages have no concept of case. The autocapitalizationType mode is ignored by the system when using the corresponding keyboards, and the field behaves the same as in .none mode, regardless of the set value.
For Arabic and Hebrew, autocapitalization also does not apply, as these languages use their own writing system without lowercase and uppercase distinction. The iOS system correctly detects the input language and ignores autocapitalization settings for languages where this concept does not exist.
Frequently Asked Questions
Yes, the autocapitalizationType property can be changed at any time, even when the field is already active. The change will take effect on the next character input.
Yes, for fields with isSecureTextEntry = true, the system automatically sets autocapitalizationType = .none. This behavior cannot be changed programmatically.
Yes, UITextView fully supports autocapitalizationType. This is especially useful for multi-line fields where .sentences mode works most naturally.
If a field is not marked as secureTextEntry but is used for password input, autocapitalization can change the password. Always disable it for fields where case matters.
On the simulator, autocapitalization works through the Mac hardware keyboard and may behave differently. Test on a real device for correct behavior.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also