多行UIAlertController消息

Jas*_*son 0 ios swift uialertcontroller

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

谢谢!

编辑:噢,它应该是\n not/n.这是正确的代码

let alertController = UIAlertController(title: "blah", message: "1. blah \n2. blah \n3. blah", preferredStyle: .actionSheet)
Run Code Online (Sandbox Code Playgroud)

PK8*_*K86 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)
Run Code Online (Sandbox Code Playgroud)