UIAlertController 更改我的按钮颜色

Dan*_*iel 5 ios uialertcontroller

UIAlertController我这样称呼:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title"
                                                                         message:@"msg"
                                                                  preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Accept" 
                                                   style:UIAlertActionStyleDefault 
                                                 handler:^(UIAlertAction *action) {/*...*/}
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
                                                       style:UIAlertActionStyleCancel 
                                                     handler:^(UIAlertAction *action) {/*...*/}];

[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

我的问题是,当UIAlertController显示时,它会将导航栏的颜色从黄色更改为白色,并将系统的灯光信息按钮从蓝色更改为灰色(它看起来没有错,它看起来像是想要的“让屏幕看起来色彩较少”效果)。如果用户当时按下主页按钮,当应用程序再次从后台进入时,应用程序将保持该颜色(这会将用户带到具有白色/灰色的登录屏幕)。

这个问题有解决方法吗?

And*_*rea 4

从 iOS7 开始,视图在显示警报视图时提供了不同的行为:

当出现警报或操作表时,iOS 7 会自动调暗其后面视图的色调。为了响应这种颜色变化,在渲染中使用tintColor的自定义视图子类应该重写tintColorDidChange以在适当的时候刷新渲染。

正如所写,你应该覆盖tintColorDidChange,检查这里