KMS*_*OFT 1 ios uialertcontroller uialertaction
我不想更改UILabel.appearance,因为它将应用于所有标签。
我如何才能显示UIAlertController如下图所示?
需要在第二个位置显示粗体按钮。

默认情况下,当我进行设置时,UIAlertActionStyle.cancel它会显示在第一个位置的“确认”按钮上。
现在看起来像这样:

我做了一些研究,但没有找到任何解决方案。
迅捷4.2 /迅捷5
您需要设置首选的操作方法,
//Create alertController
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
//Create and add the Confirm action
let confirmAction = UIAlertAction(title: "Confirm", style: .default, handler: { (action) -> Void in
//Do Something here...
})
alert.addAction(confirmAction)
//Create and add the Cancel action
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
//Do Something here...
})
alert.addAction(cancelAction)
// Set Preferred Action method
alert.preferredAction = confirmAction
self.present(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
输出将是