iOS 7 Bugs – The Status Bar and Modal View Controllers

In iOS 7, the status bar and navigation bar are now unified. The status bar is translucent which is suppose to merge seamlessly with the navigation bar. This works great for the most part until you try to present a view controller or use a modal segue in storyboards.

[self presentViewController:myViewController animated:YES completion:nil];

Screen Shot 2013-09-20 at 4.12.57 PM

Using these options causes the status bar to overlay into the navigation bar.
StatusOverlay

To fix this you can add a top constraint of 20 pixels but then your left with a white status bar that doesn’t match your navigation bar.
BrokenStatus

Workaround
A quick workaround to solve this is to add a view behind your status bar that’ll match your navigation bar.

UIView *fixItView = [[UIView alloc] init];
fixItView = CGRectMake(0, 0, 320, 20);
fixItView = [UIColor colorWithRed:0.973 green:0.973 blue:0.973 alpha:1]; //change this to match your navigation bar
[self.view addSubview:fixItView];

Of course this workaround is rather hackish and will only work with iOS 7. If you plan to support both iOS 6 and iOS 7, you can solve this problem by presenting a UINavigationController .

MyViewController *vc = [MyViewController new];
UINavigationController *nav = [[UINavigationController alloc] 
    initWithRootViewController:vc];
[self presentViewController:nav animated:YES completion:NULL];

The Result
FixedStatus

Stay tuned for more iOS 7 bugs!

6 thoughts on “iOS 7 Bugs – The Status Bar and Modal View Controllers

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Do the Math      
 

*