Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make first letter uppercase in a UILabel?

I'm developing an iPhone app. In a label, I want to show an user's first letter of the name uppercase. How do I do that?

like image 284
HardCode Avatar asked Jan 26 '12 17:01

HardCode


People also ask

How do you convert the first character of a string to uppercase?

The toUpperCase() method converts the string to uppercase. Here, str. charAt(0). toUpperCase(); gives J.

How do you capitalize the first letter of a string in Objective C?

Just use the capitalizedString method. A string with the first character from each word in the receiver changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.


1 Answers

If there is only one word String, then use the method

-capitalized

let capitalizedString = myStr.capitalized // capitalizes every word 

Otherwise, for multi word strings, you have to extract first character and make only that character upper case.

like image 63
beryllium Avatar answered Sep 19 '22 13:09

beryllium