【问题标题】:changing Font-size of UIAlertAction's button title of UIAlertController using Swift in iOS在 iOS 中使用 Swift 更改 UIAlertAction 的 UIAlertController 按钮标题的字体大小
【发布时间】:2017-06-12 06:26:20
【问题描述】:
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)

任何人都可以告诉我是否可以在 swift 中更改警报操作按钮

【问题讨论】:

  • no 是不可能的,如果你需要这样,那么你可以使用 customViews

标签: ios swift alert uialertcontroller uialertaction


【解决方案1】:

没有可用于执行此操作的公共 API。即使您能够实现这一点,也将通过私有 API 实现,这会导致应用在审核时被拒绝。

您可以查看 NSHipster 的这篇文章,其中包含 UIAlertController 的基本样式:http://nshipster.com/uialertcontroller/

此外,如果您希望更改警报中的字体颜色。只需在 alert 中更改视图的 tintColor。

alert.view.tintColor = UIColor.green /// where alert is UIAlertController object

【讨论】:

    猜你喜欢
    • 2019-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 1970-01-01
    • 2018-02-14
    相关资源
    最近更新 更多