[英]Status bar color does not match navigation bar
I have a view controller I am presenting modally. 我有一个模态呈现的视图控制器。 I want the status bar color to match the navigation bar color.
我希望状态栏颜色与导航栏颜色匹配。
I have set UIViewControllerBasedStatusBarAppearance to YES because I don't want this change across the entire application. 我将UIViewControllerBasedStatusBarAppearance设置为YES,因为我不希望在整个应用程序中进行此更改。
I am setting self.navigationController.navigationBar.barTintColor but this is only changing the navigation bar color. 我正在设置self.navigationController.navigationBar.barTintColor,但这只是更改导航栏的颜色。 The status bar remains a lighter color.
状态栏保持较浅的颜色。
I have tried various combinations of setNeedsStatusBarAppearanceUpdate and preferredStatusBarStyle but none have any effect. 我已经尝试过setNeedsStatusBarAppearanceUpdate和preferredStatusBarStyle的各种组合,但是没有任何作用。
View controller is launched like so: View Controller的启动方式如下:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
My steps are below, check where you go wrong: 我的步骤如下,请检查您出了什么问题:
Code is below: 代码如下:
- (IBAction)clickAction:(UIButton *)sender {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController2 *searchController = [sb instantiateViewControllerWithIdentifier:@"ViewController2"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navigationController animated:YES completion:nil];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.