且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Swift iOS大写字符串中的每个单词

更新时间:2022-11-09 09:32:25

您在寻找 capitalizedString


讨论

每个单词中第一个字符的字符串更改为相应的大写字母值,并将所有剩余字符设置为相应的小写值。

Discussion
A string with the first character in each word changed to its corresponding uppercase value, and all remaining characters set to their corresponding lowercase values.

和/或 capitalizedStringWithLocale(_: )

使用指定的语言环境返回接收者的大写表示。

Returns a capitalized representation of the receiver using the specified locale.

对于提供给用户的字符串,传递当前语言环境([NSLocale currentLocale ])。要使用系统区域设置,请传递nil。

For strings presented to users, pass the current locale ([NSLocale currentLocale]). To use the system locale, pass nil.