多行UIAlertController消息

时间:2017-07-05 23:42:58

标签: ios swift uialertcontroller

有没有办法格式化UIAlertController的消息(而不是标题)字符串以显示多行?我尝试了“/ n”字符,但这不起作用。我也不能使用NSString并格式化它。

谢谢!

编辑:我应该是\ n not not / n。这是正确的代码

let alertController = UIAlertController(title: "blah", message: "1. blah \n2. blah \n3. blah", preferredStyle: .actionSheet)

1 个答案:

答案 0 :(得分:5)

它将与编辑后的\n一起使用。

let alert = UIAlertController(title: "Title",
                              message: "message: \n message",
                              preferredStyle: UIAlertControllerStyle.alert)

let cancelAction = UIAlertAction(title: "OK",
                                 style: .cancel, handler: nil)

alert.addAction(cancelAction)
self.present(alert, animated: true, completion: nil)
相关问题