Eclipse Kim
Eclipse Kim

Reputation: 17

ios 7 status bar and navigation bar issue

My app's view is overlapped with status bar and navigationBar in ios7 device so I tried lots of solutions

but none of these worked. My last trial was adding these lines to appdelegate's didFinishLaunchingWithOptions

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
application.statusBarStyle = UIStatusBarStyleLightContent;
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
    self.window.clipsToBounds =YES;
} else {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
}

It works quite well when navigation bar is hidden but when nagivigation is not hidden, navigationbar's frame is (0, 20, 320, 44) not (0, 0, 320, 44) So navigationBar's height seems to be 64.. why is this? Hope someone explains me! Thanks is advance :)

Upvotes: 0

Views: 1321

Answers (3)

Jack
Jack

Reputation: 16855

Make sure you set this in viewWillAppear:

self.navigationController.navigationBar.translucent = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;

Upvotes: 1

jbrodriguez
jbrodriguez

Reputation: 119

To avoid the overlapping with the UINavigationBar, you must set its translucent property to NO.

As for the status bar, you have to manually set it by specifying its style and then reposition the whole window's frame. I would add on top of that an iOS 7 condition to make sure that only happen with users running iOS 7.

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {

    [application setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window.clipsToBounds =YES;
    self.window.frame =  CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height - 20); 
} 

Upvotes: 0

Tommie C.
Tommie C.

Reputation: 13181

For a better explanation of the differences please see this transition guide (link).

Upvotes: 2

Related Questions