ios - 在 iOS 中使用 Swift 更改 UIAlertAction 的 UIAlertController 按钮标题的字体大小

标签 ios swift alert uialertcontroller uialertaction

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/

相关文章:

objective-c - SCLAlertView 未显示

ios - 如何在 iOS7 中以编程方式找到连接 3G 网络或 Wifi 的 iPhone 设备

ios - 从 SafariWebController 返回后出现 Swift 白屏

ios - TKChartDataPoint 不符合预期的类型序列

swift - iTunes 是否备份核心数据?

html - 我可以使用 css 将 HTML 警告框格式化为我的颜色和样式吗?

ios - 加载网页时事件指示器不隐藏

ios - 将 AlertRow 与 Eureka 一起使用 如何在触摸外部任何地方时关闭警报窗口

swift - iOS 上的 Firebase 短信验证 - 'Token Mismatch'

iOS5 自定义窗口旋转问题