1

I am trying to make my status bar background color the same as my navigation bar, I was trying to find the answer in google but it does not work clearly for me... Can you please explain how it works and how can I fix it?

enter image description here

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
John E.
  • 321
  • 4
  • 11
  • As an addendum to your post, it's worth clarifying that the status bar doesn't actually have a colour on iOS. Instead, it's transparent, and it's down to you to make sure your view puts a meaningful colour behind it. In your case, it's this orange-ish colour, but you could (if you chose to) add a white box at the top behind the status bar. I would suggest that the `UINavigationController` is easier and cleaner, but there are alternatives. – TwoStraws Dec 14 '15 at 11:11

2 Answers2

0

It looks to me like you have a UINavigationBar up there, which is what's causing the gap at the top. If you are able to, embed your view controller in a UINavigationController instead, then set your navigation item buttons in code. This gives you the same effect, but also automatically ensures the status bar matches the look of its navigation bar.

TwoStraws
  • 12,862
  • 3
  • 57
  • 71
  • @AntonSergeyev: Glad it worked! Don't forget to mark my answer as correct so others can benefit too. Thanks! – TwoStraws Dec 14 '15 at 11:21
0

Goto your app info.plist

1) Set View controller-based status bar appearance to NO 2) Set Status bar style to UIStatusBarStyleLightContent

Then Goto your app delegate and paste the following code where you set your Windows's RootViewController.

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
    {
        UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 20)];
        view.backgroundColor=[UIColor blackColor];
        [self.window.rootViewController.view addSubview:view];
    }
Nikunj5294
  • 391
  • 3
  • 14