0
votes

I'm trying to change the colour of the arrow for the back button in the navigation bar. I've been able to change the text colour, but not the arrow. Here is my code to change the text colour:

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                          [UIColor whiteColor], UITextAttributeTextColor,
                                                          nil] forState:UIControlStateNormal];

If anyone could advise me on how to change the arrow coliur, that would be very helpful!

1

1 Answers

2
votes

You can use images like this to change the background of back button:

UIImage *buttonBack30 = [[UIImage imageNamed:@"button_back_textured_30"]
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)];
UIImage *buttonBack24 = [[UIImage imageNamed:@"button_back_textured_24"]
    resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 5)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack30
    forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24
    forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];

Source: RAYWENDERLICH

If you don't want to use images, you can change the tintcolor of navigation bar, because it determines the color of text of bar button item:

[[UINavigationBar appearance] setTintColor:[UIColor yourColor]];