UIAlertController更改字体颜色 [英] UIAlertController change font color

查看:185
本文介绍了UIAlertController更改字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我创建UIAlertController的代码

Here's my code that creates the UIAlertController

    // Create the alert controller
    var alertController = UIAlertController(title: "Are you sure you want to call \(self.number)?", message: "", preferredStyle: .Alert)

    // Create the actions
    var okAction = UIAlertAction(title: "Call", style: UIAlertActionStyle.Default) {
        UIAlertAction in
        var url:NSURL = NSURL(string: "tel://\(self.number)")!
        UIApplication.sharedApplication().openURL(url)
    }

    var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
        UIAlertAction in

    }

    // Add the actions
    alertController.addAction(okAction)
    alertController.addAction(cancelAction)

    // Present the controller
    self.presentViewController(alertController, animated: true, completion: nil)

我无法弄清楚如何更改取消和调用操作的文本颜色。标题文本目前为黑色,取消和呼叫按钮为白色。我正在努力让它们全黑,以提高能见度。有任何想法吗?谢谢!

I can't figure out how to change the text color of the cancel and call actions. The title text is currently black and the cancel and call buttons are white. I'm making to make them all black for better visibility. Any ideas? Thanks!

推荐答案

经过一些反复试验后,我发现这很有效。希望这将有助于未来的快速新人!

After some trial and error, I found this worked. Hopefully this will help future swift newcomers!

alertController.view.tintColor = UIColor.blackColor()

这篇关于UIAlertController更改字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆