Question

I created my status bar with following code in appDelegate class.

   UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320, 20)];
        theView.backgroundColor = customGrayColor;
        [self.window.rootViewController.view addSubview:statusBarView];

Now I want to hide it in one of the viewCOntrollers dynamically. I'm hiding both Navigation bar and the status bar.

    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    [self.navigationController setNavigationBarHidden:YES];

I can see the status bar has been hidden, as all the text does hide, but just the gray colored view doesn't hide.

And scope of problem is only iOS 7.

Was it helpful?

Solution

By calling [[UIApplication sharedApplication] setStatusBarHidden:YES]; you hide native application status bar that is instance of UIStatusBar class. But it doesn't hide your custom view statusBarView that is instance of UIView class.
For hiding custom view call:
statusBarView.hidden = YES;
or
[statusBarView removeFromSuperView].

If you need hide it from ViewController then consider adding property to AppDelegate for storing statusBarView and accessing it from any other place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top