1

I am using status bar in my app and wanted to maintain the compatibility between ios 6 and ios 7. I wanted status bar to behave same as ios 6. I don't want status bar to overlap view controllers.

Parvezkhan
  • 381
  • 1
  • 2
  • 15
  • You need to look up good ways to check for iOS 7, then read up on the differences between iOS 6 and 7 status bars. There is a lot of documentation, it's been out for months. – Jessedc Jan 13 '14 at 06:07
  • This has been answered a million times. http://stackoverflow.com/questions/18294872/ios-7-status-bar-back-to-ios-6-style – Jessedc Jan 13 '14 at 06:08
  • possible duplicate of [iOS 7 - Status bar overlaps the view](http://stackoverflow.com/questions/18775874/ios-7-status-bar-overlaps-the-view) – Balram Tiwari Jan 13 '14 at 06:08

4 Answers4

0

Try adding the following code in your view's viewWillAppear function:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    // if this is ios7 this code will make the view appear properly below the navigation bar
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = YES;
    }
}
Mike
  • 9,765
  • 5
  • 34
  • 59
0

Try this~

if(OVER_IOS7){
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [self.navigationController.navigationBar setTranslucent:NO]
}
Steven Jiang
  • 1,006
  • 9
  • 21
0

Try this.

add this key into info.plist file

View controller-based status bar appearance

set value for this to:- No

Aklesh Rathaur
  • 1,837
  • 18
  • 19
0

In iOS 7, the status bar is transparent, and other bars—that is, navigation bars, tab bars, toolbars, search bars, and scope bars—are translucent. As a general rule, you want to make sure that content fills the area behind the bars in your app.

Most bars also draw a blur behind them, unless you provide a custom background image for the bar.

iOS 7 introduces the barPosition property for identifying bar position, which helps you specify when a custom background image should extend behind the status bar. The UIBarPositionTopAttached value means that a bar is at the top of the screen and its background extends upward into the status bar area. In contrast, the UIBarPositionTop value means that a bar is at the top of its local context—for example, at the top of a popover—and that it doesn’t provide a background for the status bar.

By default, all bar buttons are borderless. For details, see Bar Buttons.

The Status Bar

Because the status bar is transparent, the view behind it shows through. The style of the status bar refers to the appearance of its content, which includes items such as time, battery charge, and Wi-Fi signal. Use a UIStatusBarStyle constant to specify whether the status bar content should be dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent):

UIStatusBarStyleDefault displays dark content. Use when light content is behind the status bar. image: ../Art/status_bar_default_iphone_2x.pngimage: ../Art/status_bar_default_ipad_2x.png UIStatusBarStyleLightContent displays light content. Use when dark content is behind the status bar. image: ../Art/status_bar_light_iphone_2x.pngimage: ../Art/status_bar_light_ipad_2x.png In some cases, the background image for a navigation bar or a search bar can extend up behind the status bar (for details, see Navigation Bar and Search Bar and Scope Bar). If there are no bars below the status bar, the content view should use the full height of the screen. To learn how to ensure that a view controller lays out its views properly, see Using View Controllers.

In iOS 7, you can control the style of the status bar from an individual view controller and change it while the app runs. If you prefer to opt out of this behavior and set the status bar style by using the UIApplication statusBarStyle method, add the UIViewControllerBasedStatusBarAppearance key to an app’s Info.plist file and give it the value NO.

Anupam
  • 555
  • 1
  • 5
  • 14