Ios UIAlertController更改我的按钮颜色
我这样调用Ios UIAlertController更改我的按钮颜色,ios,uialertcontroller,Ios,Uialertcontroller,我这样调用UIAlertController: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"msg"
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
时,它会将导航栏的颜色从黄色变为白色,系统的灯光信息按钮从蓝色变为灰色(看起来没有错,它看起来更像是想要的“让屏幕看起来不那么多彩”效果)。如果用户在那一刻按下home按钮,当应用程序再次从后台进入时,应用程序将保持该颜色(这会将用户带到登录屏幕,该屏幕为白色/灰色)
是否有解决该问题的方法?自iOS7以来,视图在显示警报视图时具有不同的行为: 当警报或行动表出现时,iOS 7会自动使屏幕变暗 为其后面的视图着色。要响应此颜色变化,请使用 在渲染中使用tintColor的自定义视图子类应 覆盖tintColorDidChange以在适当时刷新渲染
如前所述,您应该覆盖
更改,检查这是有意的,并且在出现任何警报时发生。这是因为在显示警报时,视图的交互部分(例如按钮)不交互
显示警报时,下方视图的tintAdjustmentMode
将更改为UIViewTintAdjustmentMode变暗。您可以实施tintColorDidChange
来响应此更改,但我认为您不应该这样做。好吧,主要是我有一个问题,因为如果用户激活了“高安全性”设置,那么窗口会被更改,UIAlertController
永远不会关闭。你知道关闭所有uiAlertController
s的好方法吗?不知道,但是我想,无论VC向它们展示什么,它们都可以作为presentedViewController
使用