1

I have develop the my iPad application in ios6 but now i want to develop that application in ios7 also , I am using .xib file and I am not using the AutoLayout i want to use the black status bar in my application and i want to make the application similar like ios 6 but the status bar is overlap on the view i use the different code like below link

Link 1 Position of navigation bar for modal view - iOS7

Link 2 iOS 7 - Status bar overlaps the view

Thanks in Advance

enter image description here

Community
  • 1
  • 1
Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56

4 Answers4

3

wont happen, two options:

  1. use a custom background image that is sized accordingly.. IIRC 44 (for navbar) + 20 (for status bar)

OR

  1. account for the 20 pixels by using a custom view which is black :D
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
  • 1
    If we use 44 + 20 pixel then we have to updated all the UI object which we used in xib file. So I dont think its right way to do. – Nirmalsinh Rathod Sep 19 '13 at 11:29
  • @daij-Djan thanks for replay but i have single xib for io6 and ios7 if i resize the xib for ios7 meand 44 pixel up or down then it affect for ios6 also i don't want to do that :) – Rushabh Sep 19 '13 at 11:33
  • 1
    @Daij-Djan : I think as per comment, if we resize the topbar image with +20 (status bar hight) and then if we have to do -20 px of our background image then it will work. Thanks :) – Nirmalsinh Rathod Sep 19 '13 at 12:22
  • is it always 20 like if user is using iphone 4 or iphone 7 the 20 would be constant? – Lightsout Apr 25 '17 at 01:37
2

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.

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. UIStatusBarStyleLightContent displays light content. Use when dark content is behind the status bar.

In some cases, the background image for a navigation bar or a search bar can extend up behind the status bar. If there are no bars below the status bar, the content view should use the full height of the screen.

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 behaviour 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.

For more details about how to use status bar with navigation controller, please refer my answer here.

Community
  • 1
  • 1
Nandha
  • 6,746
  • 2
  • 23
  • 33
  • It's copied directly from Apple's documentation, without credit or a link. Here's the original: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW1 – arlomedia Mar 05 '14 at 00:23
1

Try below to do not overwrite status bar:

[navController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navBar.png"] forBarPosition:UIBarPositionTop barMetrics:UIBarMetricsDefault];
spaleja
  • 1,435
  • 15
  • 24
1

A workaround to use the old style status bar is to modify the frame of the main view and shift it down 20px. This will only work on viewWillAppear function but you need to make sure you call this once. This is more of a hack than a solution:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
[self.view setFrame: CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y+20, self.view.frame.size.width, self.view.frame.size.height-20)];
}
Bms270
  • 1,586
  • 15
  • 18
  • Will the reverse solution work for ios 6 ? if i want to shift it up ? – Coldsteel48 Dec 12 '13 at 13:19
  • I haven't tried that. If you need to hide the status bar in iOS6 your can try: [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; – Bms270 Dec 12 '13 at 14:53
  • I have just tried it self.view.frame.origin.y-20 just doesnt work :( – Coldsteel48 Dec 12 '13 at 15:07
  • Why do you want to move up the view in iOS6? the view in iOS6 starts from below the status bar. Do you want to cover the status bar? The easier way if you do not want the status bar is to hide it in iOS6. – Bms270 Dec 13 '13 at 04:43
  • I did my project for iOS 7 now I have to support ios6 :(,in my iOS7 I left 20 px white line for the status bar. – Coldsteel48 Dec 13 '13 at 08:12
  • In that case you should use the delta variable in IB. You can select the view option in the file Inspector as iOS6/iOS7 and then you can adjust delta Y in the size inspector. Depending on your base OS, you either need to -20 or 20 in delta Y. You need to adjust that for the main view of your controller. – Bms270 Dec 13 '13 at 18:11
  • thanks for your answer, well i just did it in every view I had and trimmed everything there (killed all the day on it) , also I dont use IB and have no idea how to use it :( since everytime I tried it never worked:) (not as expected) . but maybe in my next project I will use it – Coldsteel48 Dec 13 '13 at 18:32