Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid the Black box appeared when hidden the navigationbar?

I have a app with main page is a hidden navigationbar ,and when I back from child page with navigationbar to this main page ,because I set the navigation hidden in the main page method: - (void)viewWillAppear, I found that a black box will appear with animation, how to avoid it? Thank you very much!!!

like image 234
jin Avatar asked Nov 18 '25 02:11

jin


2 Answers

Ok , I find the answer:

self.navigationController.view.backgroundColor = [UIColor redColor];
like image 160
jin Avatar answered Nov 20 '25 16:11

jin


This fixes the problem without hacking the colour, which could lead to navigation controllers being the wrong colour.

Just set it to be animated in viewWillAppear :)

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

and if you go back to page with nav controller set Animation to NO

- (IBAction)backButtonClicked:(id)sender {
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    [self.navigationController popToRootViewControllerAnimated:YES];
}
like image 39
HannahCarney Avatar answered Nov 20 '25 17:11

HannahCarney



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!