Reputation: 71
I'm developing an app where i want the navigationBar to be invisible and have a dark background. I want the status bar colour to be white. I also want the status bar to be hidden initially.
I have set the Status Bar Style to Light
But the result i get is always black colour text status bar as shown below.
I have tried to set the "View controller-based status bar appearance" to NO and the result was to have a hidden status bar. I also tried to have prefersStatusBarHidden returning NO but still the same.
I have tried to "View controller-based status bar appearance" to YES and the result was black text. I tried to have preferredStatusBarStyle returning UIStatusBarStyleLightContent but still the same.
I'm i doing something wrong. Thanks in advance.
Upvotes: 1
Views: 155
Reputation: 71
The problem was cause to the UINavigationController the initial view controller was embedded in. I have subclassed UINavigationController (NLNavigationController) and set the custom class of the initial navigation controller to this (NLNavigationController). In the new subclass i had this.
- (void)viewDidLoad {
[super viewDidLoad];
[self setNeedsStatusBarAppearanceUpdate];
}
-(BOOL)prefersStatusBarHidden{
return NO;
}
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
For all this to work i had to set in the info.plist
View controller-based status bar appearance set to YES
With this changes i got the following result.
https://i.sstatic.net/x88Ae.png
Upvotes: 0
Reputation: 626
AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.statusBarStyle = .lightContent
return true
}
Upvotes: 0