I'd like to separately control Show and Hide NavigationBar
and StatusBar
or each screens in my application.
On iPhone6, iPhone7 and iPhone8, it's OK.
But on iPhoneX, when NavigationBar
is shown, StatusBar
is shown together even if prefersStatusBarHidden
is set as YES.
And the height of NavigationBar
is taller by that of StatusBar
I'd appreciate if you would tell me a good resolution.
Thank you.
My code is like below,
FirstViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = UIColor.yellowColor;
self.navigationController.navigationBarHidden = YES;
} }
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden = YES;
}
- (void)touchUpButton:(UIButton *)button
{
SecondViewController *vc = [[SecondViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
SecondViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBarHidden = NO;
self.navigationItem.title = @"SecondView";
self.view.backgroundColor = UIColor.cyanColor;
}
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden = NO;
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}