UIAlertController中的默认首字母大写

时间:2015-06-28 07:03:33

标签: ios swift

当我显示UIAlertController时,有没有办法将第一个字母默认为大写

var alertController = UIAlertController(title: i18nEnterPersonName, message: nil, preferredStyle: .Alert)
// initialization of alertController...
presentViewController(alertController, animated: true, completion: nil)

1 个答案:

答案 0 :(得分:2)

这样做:

 let alertMessage = "i18nEnterPersonName".capitalizedString
 var alertController = UIAlertController(title: alertMessage, message: nil, preferredStyle: .Alert)

如果i18nEnterPersonName是变量的(我认为它是一个字符串),那么这样做:

 var alertController = UIAlertController(title: i18nEnterPersonName.capitalizedString, message: nil, preferredStyle: .Alert)