How to make the text of UITextField to appear with First letter Capital in iPhone

IosIphoneUitextfield

Ios Problem Overview


I have a text box and I am only interested in capitalizing the first letter, So how to do that in iPhone UITextField.

Ios Solutions


Solution 1 - Ios

try this:

tf = [[UITextField alloc] init];
tf.autocapitalizationType = UITextAutocapitalizationTypeSentences;

or set this property in the properties inspector in Interface Builder

Solution 2 - Ios

Swift 3 :

textField.autocapitalizationType = .sentences
textField.autocapitalizationType = .words
textField.autocapitalizationType = .allCharacters

Output :

  • Sentences : This is text input.

  • Words : This Is Text Input.

  • All characters : THIS IS TEXT INPUT.

Solution 3 - Ios

In the Attributes Inspector, near the bottom of the Text Field section, there is a setting called Capitalization with a drop down menu. Here, you can select Words, Sentences, or All Characters.

enter image description here

Solution 4 - Ios

In the Attributes Inspector , there is a Capitalization with a drop down menu. Here, you can select Words, Sentences, or All Characters.

  • Word : if you select Word than first character of every word is Capital
  • Sentences : if you Sentence than first character of First word of every sentence is Capital
  • All Characters : All Characters are Capital

Solution 5 - Ios

Swift:

tf.autocapitalizationType = .sentences

Solution 6 - Ios

Select your text field ,go in interface builder(properties option) storyboard there is a option Capatalization set it to sentence.enjoy!!!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrkbView Question on Stackoverflow
Solution 1 - IosennuikillerView Answer on Stackoverflow
Solution 2 - IosKetan PView Answer on Stackoverflow
Solution 3 - IosjungledevView Answer on Stackoverflow
Solution 4 - IosNipul DakiView Answer on Stackoverflow
Solution 5 - IosMike.RView Answer on Stackoverflow
Solution 6 - IosM.HamzaView Answer on Stackoverflow