Changing the status bar text color in splash screen iOS 7

…衆ロ難τιáo~ 提交于 2019-11-27 10:46:15

In the project plist file add the "Status Bar Style" property (key is UIStatusBarStyle). Then ignore all the possible values listed in the drop down for this property and type UIStatusBarStyleLightContent instead.

And you don't have to set UIViewControllerBasedStatusBarAppearanceto NOin your plist, you can set the preferredStatusBarStyle you want to your view controllers.

You can do this without writing any line of code
Do the following to make the status bar text color white through the whole app

On you project plist file:

  • Status bar style: UIStatusBarStyleLightContent
  • View controller-based status bar appearance: NO
  • Status bar is initially hidden: NO

You can do the following things for getting light color status bar throughout the application.

  1. Select the name of the project in the project navigator.
  2. Select the name of a target from the list in the left column of the project editor.
  3. Click General at the top of the project editor.
  4. Set Status Bar Style -> Light

In your plist file add the following values:

  1. Status bar style - UIStatusBarStyleLightContent
  2. View controller-based status bar appearance - NO

This will help you to get the status bar in WHITE colour throughout the application including SPLASH SCREEN.

Preejith augustine

Set the UIViewControllerBasedStatusBarAppearance to No in the plist

Then add the following code in did finish launch option

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

   [application setStatusBarStyle:UIStatusBarStyleLightContent];

    self.window.clipsToBounds =YES;

    self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}

Please follow this code it worked for me

Here is Apple Guidelines/Instruction about status bar change.

Here is - How to change status bar style:

If you want to set status bar style, application level then set UIViewControllerBasedStatusBarAppearance to NO in your `.plist' file.

if you wan to set status bar style, at view controller level then follow these steps:

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file, if you need to set status bar style at UIViewController level only.
  2. In the viewDidLoad add function - setNeedsStatusBarAppearanceUpdate

  3. override preferredStatusBarStyle in your view controller.

-

override func viewDidLoad() {
    super.viewDidLoad()
    self.setNeedsStatusBarAppearanceUpdate()
}

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

Set value of .plist according to status bar style setup level.


You can set background color for status bar during application launch or during viewDidLoad of your view controller.

extension UIApplication {

    var statusBarView: UIView? {
        return value(forKey: "statusBar") as? UIView
    }

}

// Set upon application launch, if you've application based status bar
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        UIApplication.shared.statusBarView?.backgroundColor = UIColor.red
        return true
    }
}


or 
// Set it from your view controller if you've view controller based statusbar
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        UIApplication.shared.statusBarView?.backgroundColor = UIColor.red
    }

}



Here is result:

You can do the following things for getting light color status bar throughout the application.

Select the name of the project in the project navigator. Select the name of a target from the list in the left column of the project editor. Click General at the top of the project editor. Set Status Bar Style -> Light

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!