First, my app's setup:
Most of the app's view controllers exist in your standard navigation controller hierarchy, but I also have a second window over the main app window, which hosts a view controller (NotificationVC
). If NotificationVC
is presenting a notification, it will change the status bar style to contrast with the notifications, but otherwise it defers the style to the main window's root view controller.
My issue is that changes in the main window that would normally trigger a status bar appearance update (pushing, popping or presenting a view controller, or calling -[UIViewController setNeedsStatusBarAppearanceUpdate]
) have no effect.
Here's the relevant code from NotificationVC
:
@implementation NotificationVC
- (UIStatusBarStyle)preferredStatusBarStyle
{
if (self.isShowingNotification)
{
if (self.notificationView.hasDarkBackground)
{
return UIStatusBarStyleLightContent;
}
else
{
return UIStatusBarStyleDefault;
}
}
else
{
return [[UIApplication sharedApplication].delegate window].rootViewController.preferredStatusBarStyle;
}
}
@end
How can I get the status bar to update from one of the view controllers in the main window?
Note: Manually setting the status bar appearance (-[UIApplication setStatusBarStyle:]
) is not an acceptable solution for this app.