StatusBar color: preferredStatusBarStyle vs. childViewControllerForStatusBarStyle

If ViewController is in a NavigationController (and the NavigationBar isn't hidden), then the StatusBar color is determined by the NavigationController:

  1. If we override preferredStatusBarStyle variable of the NavigationController, we will get the desired color.

  2. If we override childViewControllerForStatusBarStyle of the NavigationController, we will get the same color as chosen ViewController (which determined by preferredStatusBarStyle variable of that ViewController).

  3. The question is: What will happen if we override the both variables?

Spoiler: Experiments show that results in all three situations are different.
The logic of situation 3) I don't understand.

PS. Looks like Xcode has a bug. If we launch app from Xcode neither preferredStatusBarStyle nor childViewControllerForStatusBarStyle isn't called at all. So StatusBar color depends on how we launch the app. But that's not related to the question.

Terms of Service

Privacy Policy

Cookie Policy