0

Apps like Facebook, Instagram and YikYak seem to have a navigation bar that's coloured, and when its swiped, it hides however, the status bar is still there with a background colour thats the same as the navigation bar?

Example:

enter image description here

Facebook Navigation Bar Shown

enter image description here

Then user swipes up (on a tableview or something) then the navigation bar hides but the status bar is still there with a coloured background.

How can I implement this?

I have achieved a coloured Navigation bar with a white status bar that hides on swipe with this code:

// Set Navigation Bar Color
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:(252/255.0) green:(103/255.0) blue:(105/255.0) alpha:1.0]];

// Set Status Bar Style
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Now I just need to figure out how to change the status bar's background colour.

I have gotten close with the following code (that I add to my app delegate didFinishLaunchingWithOptions) that adds a coloured view, however it adds the view to the very top of my view controller hierarchy, where as I just want to add the view to my table view controller.

UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 20)];
 view.backgroundColor=[UIColor colorWithRed:(252/255.0) green:(103/255.0) blue:(105/255.0) alpha:1.0];
 [self.window.rootViewController.view addSubview:view];

Does anyone know how to ether add this view to just one of my view controllers, or a better way to do this?

Josh
  • 735
  • 1
  • 7
  • 22
  • see this answer : http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7 – Teja Nandamuri Sep 22 '15 at 20:28
  • @Mr.T I checked out the answer and it only seems to comment on changing the status bar colour, not the background colour of it? – Josh Sep 22 '15 at 20:34
  • That looks like a custom view that covers the bounds of the status bar + navigation bar. The size of the view stops at the height or top-space of the status bar when scrolling. – sooper Sep 22 '15 at 21:34

0 Answers0