When ill try to change the text-color of me StatusBar in iOS, there is always a delay for maybe 1-2 seconds. So it starts with black, and after that delay its getting white, as i want to.
All these changes are in my ViewController, in ViewDidLoad.
Ill use a custom view to get an specific color:
let statusBarHeight = CGFloat(20)
let colorBGView = UIView(frame: CGRectMake(0, -statusBarHeight, self.view.bounds.width, statusBarHeight))
colorBGView.backgroundColor = UIColor.customDarkerGrey()
self.navigationController?.navigationBar.addSubview(colorBGView)
And set the barStyle to Black (to get the white color font when using an UINavigationController)
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
Set the Value for:
View controller-based status bar appearance
In the plist.info to "YES"
But there is still a "lag" - so everything is white, but it takes up to 2 seconds. Any ideas?
Ill found not an answer question, because this is only about coloring, not for the problem with the delay:
preferredStatusBarStyle isn't called
Edit:
Ok, after creating a new Project with 2 ViewControllers and a NavigationController ill found out, that the "Delay" is normal, when you try to change the Color from ViewController to ViewController. It seems, that the function:
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
Is called with a little delay - and nothing happens when ill add:
self.setNeedsStatusBarAppearanceUpdate()
So in my case ill changed it globally on the NavigationController, and (because its loaded with my App) you do not recognize the "delay".
Maybe this is helpful for someone else.
setNeedsStatusBarAppearanceUpdate
inviewWillAppear:
– par