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

标签 ios swift

是否有函数可以将字符串中的每个单词大写,或者这是一个手动过程?

例如“鲍勃很高” 我想要“Bob Is Tall”

肯定有一些东西,但我发现的 Swift IOS 答案似乎都没有涵盖这一点。

最佳答案

你在找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.

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

关于ios - 如何使用 Swift iOS 将字符串中的每个单词大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29261218/

相关文章:

ios - 如何动态地将动态大小的 UIButtons 插入到 UIStackView 中?

android - 将 Flash 游戏导出为 "embedables"到 iOS 和 Android

html - 更改Swift NSAttributedString的无序列表的字体

ios - localNotification/uiTableView/删除行 -> 错误 "invalid number of rows"

javascript - 快速按钮 vs 消除 ios UIWebView 上的触摸延迟?

ios - 相当于Android中的getLastKnownLocation的iOS

swift - 自定义导航栏在转到另一个 View 时重叠

ios - 如何使用 Storyboard 在消失的导航栏上添加栏按钮项目?

ios - 如何将 UIButton 左对齐,UILabel 右对齐。喜欢 instagram 的评论

ios - 滚动 UITableView 时复选标记消失