0

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.

Community
  • 1
  • 1
iniyan
  • 131
  • 3
  • 15

2 Answers2

1
  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.

Puttin
  • 1,596
  • 23
  • 27
0

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.

Community
  • 1
  • 1
itnAAnti
  • 652
  • 8
  • 17