14

I have changed my navigation bar color via the following code

navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:@"faf6f5"];

The code worked but the text color also needs to be changed (see screenshot below). Also the refresh button logo on the right is affected as well

enter image description here

The same issue occurs if I navigate to another page in the stack

enter image description here

Question: How can I change the color of the

  • title text
  • Back button text and
  • right bar button icon color?

After I changed the background color of the navbar?

Zhen
  • 12,361
  • 38
  • 122
  • 199

4 Answers4

18

In iOS 7, just use:

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};

Change [UIColor whiteColor] with whatever text color you want

Erwan
  • 3,733
  • 30
  • 25
15

For the title here's the way:

iPhone Navigation Bar Title text color

And for the custom buttons here's the way:

adding buttons to ui navigation controller bottom bar

Community
  • 1
  • 1
Erre Efe
  • 15,387
  • 10
  • 45
  • 77
  • 1
    Rincon-Fadul, thanks for the links, the first link works well for me. However, I am still not sure how I can change the button's text color or icon color. For icon, I probably can change the image directly. But what about the back button text color for instance? The link doesn't really explain about that part – Zhen Jul 24 '11 at 15:51
  • Old answer, use @Erwan's one – Zeb Jun 24 '15 at 09:08
7

To change text color:

_navController.navigationBar.titleTextAttributes 
         = @{UITextAttributeTextColor : [UIColor blackColor]};

Adding refresh button and color it:

UIBarButtonItem *button = [[UIBarButtonItem alloc]
         initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
         target:self action:@selector(reload)];

[button setTintColor:[UIColor blackColor]];
self.navigationItem.rightBarButtonItem = button;

Variables that effect navigation bar background:

_navController.navigationBar.backgroundColor = [UIColor whiteColor];
_navController.navigationBar.tintColor = [UIColor whiteColor];
_navController.navigationBar.translucent = NO;
hasan
  • 23,815
  • 10
  • 63
  • 101
1

I just put together a simple UIViewController subclass that adds a customizable back button that allows you to change text colors. It basically adds some willAppear/willDisappear logic to animate the back button the way the UINavigationController does while using the leftBarButtonItem property. You might extend this to also do the rightBarButtomItem as well.

https://github.com/typeoneerror/BBCustomBackButtonViewController

typeoneerror
  • 55,990
  • 32
  • 132
  • 223