0
votes

iOS8.1(xcode 6.1) I used the below method to change the status bar text color.

[self setNeedsStatusBarAppearanceUpdate];

-(UIStatusBarStyle)preferredStatusBarStyle{ 
return UIStatusBarStyleLightContent; }

following the link preferredStatusBarStyle isn't called

But this is not working for me.Anyone knows how to change status bar color related to uinavigationcontroller.

2

2 Answers

1
votes
  1. set UIViewControllerBasedStatusBarAppearance to YES in your info.plist
  2. override - (UIViewController *)childViewControllerForStatusBarStyle in your navigationController. return your childVC
  3. override preferredStatusBarStyle or something need.

code:

- (UIStatusBarStyle)preferredStatusBarStyle{
    return self.test?UIStatusBarStyleLightContent:UIStatusBarStyleDefault;
}

- (IBAction)test:(id)sender {
    self.test = !self.test;
    [self setNeedsStatusBarAppearanceUpdate];
}

let me know if it don't work.

0
votes

You can customize the title text style on UINavigationControllers by assigning an NSDictionary containing your settings to the titleTextAttributes property.

NSDictionary *titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            [UIColor whiteColor], NSForegroundColorAttributeName, nil];

[[UINavigationBar appearance] setTitleTextAttributes:titleTextAttributes];

More stack overflow discussion here, and apple ref here.