rkb
rkb

Reputation: 11231

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

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

Upvotes: 66

Views: 42283

Answers (6)

Ketan P
Ketan P

Reputation: 4379

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.

Upvotes: 49

Mike.R
Mike.R

Reputation: 2938

Swift:

tf.autocapitalizationType = .sentences

Upvotes: 4

ennuikiller
ennuikiller

Reputation: 46965

try this:

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

or set this property in the properties inspector in Interface Builder

Upvotes: 118

jungledev
jungledev

Reputation: 4335

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

Upvotes: 22

Nipul Daki
Nipul Daki

Reputation: 371

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

Upvotes: 6

M.Hamza
M.Hamza

Reputation: 49

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

Upvotes: 3

Related Questions