How to make first letter uppercase in a UILabel?

HardCode picture HardCode · Jan 26, 2012 · Viewed 41.6k times · Source

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?

Answer

beryllium picture beryllium · Jan 26, 2012

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.