我不想更改 UILabel.appearance
,因为它将适用于所有标签。
如何显示如下图所示的 UIAlertController
?
需要在第二个位置显示粗体按钮。
默认情况下,当我设置 UIAlertActionStyle.cancel
时,它会在第一个位置的确认按钮上显示它。
现在看起来像这样:
我做了一些研究,但没有找到任何解决方案。
最佳答案
Swift 4.2/Swift 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)
输出将是,
关于ios - 如何更改 UIAlertAction 字体或在第二个位置显示 UIAlertActionStyle.cancel 样式 ActionButton?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48555399/