Vibhooti
Vibhooti

Reputation: 1203

status bar overlaps with navigation bar

I am adding navigation controller through code, in my application. All other thing work fine, but my navigation bar overlaps with the status bar.I have tried by adding  

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone; 

but it is not working.

My other controllers in that navigation controller are in xibs only not storyboard. Please help.

Upvotes: 1

Views: 175

Answers (2)

Boggarapu
Boggarapu

Reputation: 333

I solved the problem with the following code (as suggested by Tacettin Özbölük):

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
    UIView *addStatusBar = [[UIView alloc] init];
    addStatusBar.frame = CGRectMake(0, 0, 320, 20);
    addStatusBar.backgroundColor = [UIColor colorWithRed:0.973 green:0.973 blue:0.973 alpha:1]; //change this to match your navigation bar
    [self.window.rootViewController.view addSubview:addStatusBar];
}

Upvotes: 1

Bhavin
Bhavin

Reputation: 27235

If you really don't want your Navigation Bar to be translucent then use this code and your problem will be solved :

self.navigationController.navigationBar.translucent = NO;

Upvotes: 1

Related Questions