tags:

views:

505

answers:

2

Hi Guys, I'm developing an app in objective-c and in that app set the navigationBar to translucent(through IB). But the problem is that the view displayed behind the navigation bar.

Anybody else tried working with translucent navigation bars?

regards

Jayaraj

+1  A: 

The [navigationController view] automatically resizes to "underlap" translucent navigation bars as of OS 3.0

You can simply add 44 pixels to the y value of the origin property to overcome this.

Corey Floyd
A: 

You can use 44 if you know you're in portrait (not landscape, in which the height of the navBar is less than 44)

You can also do:

// applicationFrame subtracts the height of the statusBar if it's visible.
// bounds doesn't take into account the statusBar.
CGRect navFrame = [[UIScreen mainScreen] applicationFrame];
NSLog(@"navFrame: %f x %f", navFrame.size.width, navFrame.size.height);
navFrame.size.height -= self.navigationController.navigationBar.frame.size.height;
NSLog(@"navFrame: %f x %f", navFrame.size.width, navFrame.size.height);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:navFrame];
NSLog(@"imageView: %@", imageView);

I learned this from reading three20's source code. You can find it on github.com

Matt

MattDiPasquale