Skip to main content

IOS6 style Navigation Bar in IOS7

By February 12, 2014Blog

So you need to create that old style look in an app, maybe because it is a legacy code and your client needs this because of approved style guides and new ones do not exist for IOS7 yet?

Then do not despair, it is easier than you think. I used appearance for UINavigationBar to set up the basics.

[[UINavigationBar appearance] setTitleTextAttributes: @{ UITextAttributeFont : SOME_FONT_IF_YOU_WISH }];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"NavBar.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
        self.window.clipsToBounds = YES;
    }

Then you need to make sure all the views are not offset by 64pixels down. It is again very simple, just force the inset to be used for non transparent navigation bar too. I call this in viewDidLoad and viewWillAppear.

- (void)updateInsetIOS7
{
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.edgesForExtendedLayout = UIRectEdgeAll;
        self.extendedLayoutIncludesOpaqueBars = YES;
    }
}

Happy coding!