如何在 iOS7 中更改 UIAlertView 的按钮文本颜色? [英] How to change button text color of UIAlertView in iOS7?

查看:19
本文介绍了如何在 iOS7 中更改 UIAlertView 的按钮文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS7 引入了通用色调.我认为 UIAlertView 也在有效范围内,但实际上 tintColor 看起来不适用于 UIAlertView.(用于可点击的按钮文本颜色)

iOS7 introduced general tint-color. I think UIAlertView is also in the valid range, but actually tintColor doesn't look to work with UIAlertView. (for tappable button text color)

是否可以更改警报视图的色调?如果可能,如何更改?

Is it possible to change the tint-color of alert view? If possible, how to change it?

推荐答案

很遗憾,您无法自定义警报视图的外观,也无法更改按钮文本颜色.

Unfortunately you cannot customize the appearance of alert views, it is impossible to change the buttons text color.

UIAlertView Class中有明确提到参考:

UIAlertView 类旨在按原样使用,而不是支持子类化.此类的视图层次结构是私有的,并且不得修改.

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

更新:

问题是关于 iOS7,但现在 UIAlertView 已弃用,对于 UIAlertController,您可以简单地更改视图色调颜色:

The question was about iOS7, but now UIAlertView is deprecated, for UIAlertController you can simply change the view tint color:

    let alert = UIAlertController(title: "Gimme a break",
                                message: "For God sake its iOS7 question!",
                         preferredStyle: .alert)
    alert.view.tintColor = UIColor.red

检查这个问题也很有帮助:如何在 iOS9 中更改 UIAlertController 按钮文本颜色?

It is helpful also to check this question: How to change UIAlertController button text colour in iOS9?

这篇关于如何在 iOS7 中更改 UIAlertView 的按钮文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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