简体   繁体   English

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

[英]changing Font-size of UIAlertAction's button title of UIAlertController using Swift in iOS

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)

Any one can tell me is it possible to change of alert action button in swift 任何人都可以告诉我是否可以迅速更改警报操作按钮

There is no public APIs available to do this. 没有可用于执行此操作的公共API。 Even if you are able to achieve this it would be through private APIs and that would lead to the app being rejected on review. 即使您能够做到这一点,也可以通过专用API进行,这将导致该应用在审核时被拒绝。

You can check this post by NSHipster that goes through the basic styles of UIAlertController: http://nshipster.com/uialertcontroller/ 您可以通过NSHipster查看有关UIAlertController基本样式的文章: http ://nshipster.com/uialertcontroller/

Furthermore, if you wish to change the color of font in the alert. 此外,如果您想更改警报中的字体颜色。 Just change the tintColor of the view in alert. 只需在警报中更改视图的tintColor。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM