Reputation: 125
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
Upvotes: 1
Views: 1744
Reputation: 361
There is no public APIs available to do this. 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.
You can check this post by NSHipster that goes through the basic styles of 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.
alert.view.tintColor = UIColor.green /// where alert is UIAlertController object
Upvotes: 1