let alertController: UIAlertController = UIAlertController(title: "Alert", message: nil, preferredStyle: .alert)
let customActionButton: UIAlertAction = UIAlertAction(title: "Custom", style: .default) { action -> Void in
}
let attrString: NSAttributedString = NSAttributedString(string: "Custom", attributes: [NSFontAttributeName: UIFont.init(name: "Roboto-Regular", size: 17.0)!])
customActionButton.setValue(attrString, forKey: "attributedTitle")
alertController.addAction(customActionButton)
present(alertController, animated: true, completion: nil)
任何人都可以告诉我是否可以快速更改警报操作按钮
最佳答案
没有可用的公共(public) API 来执行此操作。即使您能够实现这一目标,也将通过私有(private) API 实现,这将导致应用在审核时被拒绝。
您可以查看 NSHipster 的这篇文章,其中介绍了 UIAlertController 的基本样式:http://nshipster.com/uialertcontroller/
此外,如果您想更改警报中的字体颜色。只需在警报中更改 View 的 tintColor。
alert.view.tintColor = UIColor.green /// where alert is UIAlertController object
关于ios - 在 iOS 中使用 Swift 更改 UIAlertAction 的 UIAlertController 按钮标题的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44492647/