0
votes

I have a view controller I am presenting modally. I want the status bar color to match the navigation bar color.

I have set UIViewControllerBasedStatusBarAppearance to YES because I don't want this change across the entire application.

I am setting self.navigationController.navigationBar.barTintColor but this is only changing the navigation bar color. The status bar remains a lighter color.

I have tried various combinations of setNeedsStatusBarAppearanceUpdate and preferredStatusBarStyle but none have any effect.

enter image description here

View controller is launched like so:

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

[self presentViewController:navigationController animated:YES completion:nil];
1
how you create the navigationbar?aircraft
View controller is embedded in a navigation controller. Code added to question.zorro2b
Yes, that's how I want it to lookzorro2b
Okay, I am sure the issue is caused by your wrong step.I will give my steps to do that.aircraft

1 Answers

0
votes

My steps are below, check where you go wrong:

  1. Create 2 view controller like below, you can let vc1 embed in a navigation controller:

enter image description here

  1. In the vc1, you drag a action of the button:

enter image description here

Code is below:

- (IBAction)clickAction:(UIButton *)sender {

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ViewController2 *searchController = [sb instantiateViewControllerWithIdentifier:@"ViewController2"];

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:searchController];

    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

    [self presentViewController:navigationController animated:YES completion:nil];
}
  1. Then in the vc2, you set the title:

enter image description here