4

I made UIViewController which have navigationController as parent (connected in storyboard), and I want to apply picture of navigationBar for statusBar background.

but it seems that statusBar can't be state like "Translucent",

I tried to set

- (void)viewWillAppear:(BOOL)animated {    
 [self.navigationController.navigationBar setBackgroundImage:[UIImage
 imageNamed:@"barTop.png"] forBarPosition:UIBarPositionTopAttached 
 barMetrics:UIBarMetricsDefault];

 [self setNeedsStatusBarAppearanceUpdate];
 ....

}
- (UIStatusBarStyle)preferredStatusBarStyle {
  return UIStatusBarStyleLightContent;
}

in UIViewController.

But backgrounds of navigation and status Bar have been separated.

enter image description here

I try both to make plist file as "View controller-based status bar appearance" YES and NO. but still I can't configure statusBar from viewController. I couldn't find same problem in this bulletin board .

does anyone knows solution??or how to debug?

thank you for reading.

(9/3 added: I want to make backgrounds together for navigationBar and statusBar.

And under the simple condition like that there are one navigationController and one ViewController, both bars can make their backgrounds together (default).

Now I met the something wrong when I make tabBarController indicate to multiple navigationController by storyboard.)

dubryu
  • 43
  • 6

2 Answers2

0

According to Apple for Status bar, status bar is Transparent.(I think* always, not sure). Here is the link. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/Bars.html

enter image description here

Arpit B Parekh
  • 1,932
  • 5
  • 36
  • 57
  • thank you yes It seems that statusBar is Transparent when default, but not in my app.. now I assume that the statusBar is already transparent , but navigationBar is placed under the Coordinate with a status bar. then I tried below with break point at viewController po self.navigationController.navigationBar but output is below error: property 'navigationBar' not found on object of type 'id' error: 1 errors parsing expression – dubryu Aug 31 '15 at 13:20
  • My dear friend, Now first you give me the answer, What is the result of. po self.navigationController – Arpit B Parekh Aug 31 '15 at 14:14
  • It means print-object(gdb), and its result of self.navigationController was – dubryu Sep 01 '15 at 09:47
  • It still had been wrong. I noticed that I had successed to change the status bar style, but navigaitonBar can't be statusBar's backGround when Its view came from kind of tabBarViewController. are there any case that method or delegate to config the state of navigationBar? and are there any method or delegate to config the state of navigationBar explicitlyby myself? – dubryu Sep 03 '15 at 11:27
  • Write each and everything very quietly. – Arpit B Parekh Sep 03 '15 at 11:40
  • Very peacefully you write your queries. Step by step you write, write how much you want but line by line. Fully explain situation. Do not worry. – Arpit B Parekh Sep 03 '15 at 11:40
  • but navigaitonBar can't be statusBar's backGround ? means You want some portion of the NavigationBar behind the status bar, Right ? – Arpit B Parekh Sep 03 '15 at 11:43
  • Are you using Default Navigation Bar or You yourself made a Navigation View. – Arpit B Parekh Sep 03 '15 at 11:44
  • I use default NavigationBar – dubryu Sep 03 '15 at 15:54
  • I added some modification for description. – dubryu Sep 03 '15 at 16:29
0

Although I found the solution this a few month ago,it took a time to align the point.

checking my viewController structure causing problem , It found Black of the statusBar is self.window.backgroundColor. so this mean status bar and navigationController was originally succeeded to be transparent, my viewController is aligned (20, 0). this was root of this problem. and I found that this problem derived from applying contentInsets setting. this setting affects to even view.subviews[0] too.

this happen when under some condition •uiViewController’s view displayed via UInavigationController •edgesForExtendedLayout is active •view’s first element is kind of UIScrollView or these subclass (from japanese bulletin board)

to solute this , I made originally navigationController on the storyBoard to separate from these inset setting then I explicitly set its origin to (0,0) and I set automaticallyAdjustsScrollViewInsets = NO on my viewController.

after that, finally I could set viewController’s origin to (0,0), and I made navigationBar’s back being statusBar’s back.

below link contains so much useful information. iOS 7 status bar back to iOS 6 default style in iPhone app?

Community
  • 1
  • 1
dubryu
  • 43
  • 6