Hiding status bar and navigation bar position

I have one issue which i can't handle with it. I have two view controllers and I use [[UIApplication sharedApplication] setStatusBarHidden:isHidden withAnimation:UIStatusBarAnimationSlide]; to show/hide status bar. All works pefect but I need one thing: everything is embed in navigation controller and after hiding status bar navigation bar is moving up for 20 px. How can I remove this effect? With or without status bar i want navigation bar at the same place in every time.

Edit1: I've already done this

    [super viewWillAppear:animated];
    self.navigationController.navigationBar.layer.transform = CATransform3DIdentity;
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    self.navigationController.navigationBar.layer.transform = CATransform3DMakeTranslation(0, 20, 0);

It works but animation is terrible and i need something better.


There's no clean way to prevent UINavigationController from adjusting the height of its navigation bar. I describe the behavior in detail in this SO answer.

The only workaround currently is that UINavigationController only performs those height adjustments whenever it's view's bounds matches the bounds of the window, i.e., if the navigation controller's view fills the screen. If the view's bounds are off, even by a pixel, it will default to a standard 44 point high navigation bar.

Karah's answer above is incorrect. UIViewControllerBasedStatusBarAppearance is used to determine the color and visibility of the status bar. It has nothing to do with UINavigationController's nav bar height logic.

There no clear way to do this, but you can set this thing by using following code in ViewDidLoad :

    CGRect statusFrame = CGRectMake(0.0, -20.0, 1024, 20);
    UIView* statusBar = [[UIView alloc] initWithFrame:statusFrame];
    statusBar.backgroundColor = [UIColor blackColor];
    [self.view addSubview:statusBar];
    [statusBar release];

When your status bar is hidden, the navigation bar automatically moves up to make up for the space.

If you set UIViewControllerBasedStatusBarAppearance to YES, it should stop that behaviour.

Need Your Help

The difference between static scope and dynamic scope

scope lexical-scope dynamic-scope

My teacher has provided the following pseudo-code, and says that the output using static scope is 1 2 3, but the output using dynamic scope is 2 3 4.

Carthage requires git 2.3.0 or later

ios terminal ios-charts carthage

I am using charts library and trying to run the demo. Before running I have to install the dependencies using Carthage. I goto project folder location and type in terminal: