0

I've succeeded setting the background color of the navigation bar to black. In the AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
    [navigationBarAppearance setBarTintColor:[UIColor blackColor]];
    [[UINavigationBar appearance] setTranslucent:NO];
    return YES;
}

Is there a way to set the navigation bar title and the icons in the status bar to white?

1 Answers1

0

For the navigation bar:

navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: yourColor};

or, using appearances

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: yourColor}];

If you want the status bar to be white throughout your entire application, set View controller-based status bar appearance to NO in Info.plist. After that, do the following in your app delegate

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self.window setBackgroundColor:[UIColor whiteColor]];

Apparently setStatusBarStyle: has been deprecated in iOS 9, so use preferredStatusBarStyle instead. To do this, add the following to each of your view controllers

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
Chris Loonam
  • 5,735
  • 6
  • 41
  • 63
  • I'm using `[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: whiteColor}];` and I get a `Use of undeclared identifier` error on the whiteColor –  Sep 18 '15 at 18:43
  • Try `[UIColor whiteColor]` instead. – Chris Loonam Sep 18 '15 at 18:46
  • It's working for the navigation bar. It's also working with icons in the status bar but it says that `setStatusBarStyle` is deprecated –  Sep 18 '15 at 18:54
  • It's working now. I'd like to ask you another question. Can I change blackColor and use a #00cc00 format? –  Sep 18 '15 at 19:05
  • I personally don't know all that much about using hex values in iOS, but [this answer](http://stackoverflow.com/a/6207457/1702077) seems as though it would help you. – Chris Loonam Sep 18 '15 at 19:08