Skip to content
Search

IOS:StatusBar

lastmod 2018-08-17created 2014-02-1020 edits

The status bar displays important information about the device and the current environment (shown below on iPhone).

Status Bar Black Error

This section summarizes how to fix the status bar (StatusBar) being rendered black, as in the image below.

Ios7_statusbar_error_sample.png

iOS7 StatusBar Style

With the update to IOS7, a few more things became controllable, and one of them is the StatusBar. It is defined in UIViewController as follows.

// These methods control the attributes of the status bar when this view controller is shown. They can be overridden in view controller subclasses to return the desired status bar attributes.
- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0); // Defaults to UIStatusBarStyleDefault

Override this function as follows.

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

iOS7 StatusBar Overlap Issue

With the iOS version update, the position of the status bar changed due to differences between versions 6 and 7. The status bar, which occupied a fixed 20px area in version 6, seems to have changed in version 7 to use an overlapping area instead of a fixed one. As a fix, add the following to the didFinishLaunchingWithOptions function of AppDelegate.

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    // [application setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window.clipsToBounds = YES;
    self.window.frame =  CGRectMake(0, 20, self.window.frame.size.width,self.window.frame.size.height - 20);
    self.window.bounds = CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height);
}

Or it can be fixed simply as follows.

CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
self.navigationController.view.frame = frame;

Favorite site

Technical Q&A: iOS7 StatusBar

iOS7 StatusBar Issues

References


  1. Iphone_-iOS_7_status_bar_back_to_iOS_6_style's_issue-_Stack_Overflow.pdf ↩

  2. Statusbar_-iOS_7_status_bar_back_to_iOS_6_style-_Stack_Overflow.pdf ↩

  3. Ios_-Status_bar_and_navigation_bar_issue_in_IOS7-_Stack_Overflow.pdf ↩

  4. IOS7_-_StatusBar_and_CustomNavigation.pdf ↩