---
title: "Fixed Height Navigation Bar On iOS 7"
description: "n iOS 7 Apple introduced new approach to status bar. It is now rendered above the navigation bar, effectively looking as a part of it. It required some efforts to adapt older applications to this new approach. If developer follows Apple suggestions and guidelines that's not really hard thing to figure out and adapt."
url: https://manytomany.co/blog/fixed-height-navigation-bar-on-ios-7/
published: 2014-08-05
---

# Fixed Height Navigation Bar On iOS 7

5 August 2014

This is an archived article from the website of Factorial Complexity Ltd., an older incarnation of many-to-many. Information may be outdated or inaccurate.

In iOS 7 Apple introduced new approach to status bar. It is now rendered above the navigation bar, effectively looking as a part of it. It required some efforts to adapt older applications to this new approach. If developer follows Apple suggestions and guidelines that’s not really hard thing to figure out and adapt.

There is, however, an obscure and undocumented issue that might cause some headache. It happens when for some reason application needs to hide and show status bar on certain view controller. Drawer-styled side menu is a good example of the case when developer might need to do this.

It is easy to hide and show status bar:

```objc
[self setNeedsStatusBarAppearanceUpdate];

// ...

- (BOOL)prefersStatusBarHidden
{
    return YES;
}
```

However, if status bar is hidden, iOS will eventually make navigation bar height smaller to compensate for status bar size. In some cases this may even affect other view controllers preseneted as modals. The mechanism of this behavior is described [here](http://blog.jaredsinclair.com/post/61507315630/wrestling-with-status-bars-and-navigation-bars-on-ios-7):

> UINavigationController will alter the height of its UINavigationBar to either 44 points or 64 points, depending on a rather strange and undocumented set of constraints. If the UINavigationController detects that the top of its view’s frame is visually contiguous with its UIWindow’s top, then it draws its navigation bar with a height of 64 points. If its view’s top is not contiguous with the UIWindow’s top (even if off by only one point), then it draws its navigation bar in the “traditional” way with a height of 44 points. This logic is performed by UINavigationController even if it is several children down inside the view controller hierarchy of your application.

To overcome this I have created [a category](https://github.com/wicharek/UINavigationBar-FixedHeightWhenStatusBarHidden) for `UINavigationBar` which completely disables navigation bar resizing if `fixedHeightWhenStatusBarHidden` is set to `YES`. Feel free to use and don’t forget star it on [Github](https://github.com/wicharek/UINavigationBar-FixedHeightWhenStatusBarHidden) if you find it useful.

![Vitalii](https://manytomany.co/vitalii-yellow.png)

## Hi. I'm Vitalii.

I’m a software developer, technical manager and solo entrepreneur. I have been building software products all my life. I am offering **CTO as a Service** at many-to-many.

## Contact me

Let me know what are you looking for. I will reach out to you via the provided email with quote and follow up questions. Alternatively, [book a call](https://calendly.com/many-to-many/intro) or reach me directy by email [hello@manytomany.co](mailto:hello@manytomany.co).

Or using your preferred messaging app:

 [![WhatsApp QR Code](https://manytomany.co/qr/qr-whatsapp.png)](https://wa.me/qr/QH6GQNCO5CZEO1)[WhatsApp](https://wa.me/qr/QH6GQNCO5CZEO1)

 [![Telegram QR Code](https://manytomany.co/qr/qr-telegram.png)](https://t.me/wicharek)[Telegram](https://t.me/wicharek)
