0
votes

In my application I am using multiple colors (based on theme) as tint of UINavigationBar for some light and some dark. In iOS7 and up that change status bar color too.

For light colors it's fine to use default status bar text color (black) but for dark ones we need to be light (white).

I have tried many approached based on different answers, to do so. Here are those:
1. View controller-based status bar appearance, but it doesn't work with UINavigationControlerbased application
2. Setting self.navigationController.navigationBar.barStyle = UIBarStyleBlack; to set status bar text color white but it doesn't change color back to black once set to white

How will it work?

1

1 Answers

1
votes

To change color on particular page you'll need to change it application wide. You can re-update is once you are leaving this page of-course.

- (void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

    // Do any additional setup after loading the view.
    if ([tintColor isEqual:[UIColor blackColor]])
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
    else
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}

- (void) viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:YES];

    //set it back to default
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}