简体   繁体   中英

How to get a black status bar on an iPhone app?

I want to use a black status bar for my iPhone app. I have selected black status bar on all of my.xibs but I still can't get it to be black. Is this an issue that anyone else has seen or knows how to remedy?

  1. Open the "info.plist" file.
  2. Add a new row.
  3. Select "Status bar style" as the key .
  4. Select "Opaque black style" as the value .

EDIT: The comment by @codrut below to choose the value:
If you go far to the right, there's a button that brings you a drop down with the possible options.

The status bar in the nib files is there as an indication, just to simulate the real interface. What you need to do is:

 [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];

and in the plist change the Status Bar Style (UIStatusBarStyle) to Black opaque (UIStatusBarStyleBlackOpaque) (or whatever you want).

Add the following in the info.plist file

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>

Not sure if this will help anyone else, but in our app we ran into an issue where the only way we could get it to use the black style was if we set it to the default style:

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];

Might be worth giving that a try if BlackOpaque isn't working for you.

Try this simple method....

1.For single viewController

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];

2.For whole application

info.plist
      ----> Status Bar Style
                  --->UIStatusBarStyle to UIStatusBarStyleBlackOpaque

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM