How to make the text of UITextField to appear with First letter Capital in iPhone
IosIphoneUitextfieldIos 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
.
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!!!