如何在iOS9中更改UIAlertController按钮文本颜色? [英] How to change UIAlertController button text colour in iOS9?

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

问题描述

问题类似于 iOS 8 UIActivityViewController和UIAlertController按钮文本颜色使用窗口的tintColor ,但在iOS 9中。

The question is similar to iOS 8 UIActivityViewController and UIAlertController button text color uses window's tintColor but in iOS 9.

我有一个UIAlertController,即使我试图设置

I have a UIAlertController and the dismiss button keeps white colour even I have tried to set

[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]];

UIAlertController *strongController = [UIAlertController alertControllerWithTitle:title
                                                             message:message
                                                      preferredStyle:preferredStyle];
strongController.view.tintColor = [UIColor black];


推荐答案

我在过去遇到过类似的事情这个问题似乎源于这样一个事实:警报控制器的视图还没有准备好在它出现之前接受 tintColor 更改。或者,尝试设置提示控制器的色调 AFTER

I've run into something similar in the past and the issue seems to stem from the fact that the alert controller's view isn't ready to accept tintColor changes before it's presented. Alternatively, try setting the tint color AFTER you present your alert controller:

[self presentViewController:strongController animated:YES completion:nil];
strongController.view.tintColor = [UIColor black];

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

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