iniyan
iniyan

Reputation: 131

How to change Status Bar text color in iOS 8 embeded with UInavigationController?

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.

Upvotes: 0

Views: 1365

Answers (2)

itnAAnti
itnAAnti

Reputation: 654

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.

Upvotes: 0

Puttin
Puttin

Reputation: 1615

  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.

Upvotes: 1

Related Questions