Search code examples
iosheightcenteruibarbuttonitemnavigationbar

ios changing navigation bar height causes leftBarButtonItem not to be centered


I'm working on a project that needs to have the navigation bar height bigger than the default.

This is how i set the nav bar height:

- (CGSize)sizeThatFits:(CGSize)size {
if (iPad) {
    CGSize newSize = CGSizeMake(768,86);
    return newSize;
}
return CGSizeMake(320, 44);}

I set an bg image for the navigation bar and that's working ok.

The problem is that the back button and the right button item are not centered.

Does anyone know how to center them?

Thanks


Solution

  • It's generally bad practice to manipulate the navigation bar's height. I tried to do it a number of different ways for one project and every approach had a "gotcha". Namely, the navigation buttons are always justified to the bottom of the navigation bar, so adjusting it's height will cause the buttons to look like they're rendering towards the bottom of the bar. And the buttons will animate oddly as you push and pop other controllers. I would suggest not adjusting the height of the navigation bar.