1
votes

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

https://i.stack.imgur.com/d4GoW.png

But the result i get is always black colour text status bar as shown below.

https://i.stack.imgur.com/6qgAu.png

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.

2
uncheck "Hide status bar"Dishant Rajput

2 Answers

0
votes

AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    UIApplication.shared.statusBarStyle = .lightContent
    return true
}
0
votes

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.stack.imgur.com/x88Ae.png