gpt4 book ai didi

ios - UIAlertController 改变了我的按钮颜色

转载 作者:可可西里 更新时间:2023-11-01 05:33:54 25 4
gpt4 key购买 nike

我这样调用 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];

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

这个问题有解决方法吗?

最佳答案

自 iOS7 以来, View 在显示警报 View 时提供了不同的行为:

When an alert or action sheet appears, iOS 7 automatically dims the tint color of the views behind it. To respond to this color change, a custom view subclass that uses tintColor in its rendering should override tintColorDidChange to refresh the rendering when appropriate.

如所写,您应该覆盖 tintColorDidChange,检查 here

关于ios - UIAlertController 改变了我的按钮颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28026089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com