Changing the status bar text color in splash screen iOS 7

IosIos7Splash ScreenStatusbarUistatusbar

Ios Problem Overview


I know that are already some stackoverflow questions that say how to change the status bar for all view controllers. I am currently changing the color of status bar this way:

if(IS_IOS7)
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

In the application:DidFinishLaunching

Additionally, I have changed the value of UIViewControllerBasedStatusBarAppearance in the plist to NO. However, in the splashscreen it stills shows the status bar text with the black color.

Is it possible to change the color of the status bar text color in the splash screen?

Ios Solutions


Solution 1 - Ios

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.

Solution 2 - Ios

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

Solution 3 - Ios

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.

Solution 4 - Ios

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

Solution 5 - Ios

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. enter image description here


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:

enter image description here

Solution 6 - Ios

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTiago AlmeidaView Question on Stackoverflow
Solution 1 - IosVinzzzView Answer on Stackoverflow
Solution 2 - IosLucasView Answer on Stackoverflow
Solution 3 - IosAnooj VMView Answer on Stackoverflow
Solution 4 - IosPreejith augustineView Answer on Stackoverflow
Solution 5 - IosKrunalView Answer on Stackoverflow
Solution 6 - IosUsman NisarView Answer on Stackoverflow