1
votes

I have background images for my UIBarButtonItems and my UINavigationBar. I am trying to use UIAppearance to customize all of them with the following:

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_btn.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

and it works very well. The only problem is the default back buttons on the UINavigationBar still use the standard iOS background color/image. When I set the TintColor on [UINavigationBar appearance] it will change the colors, but that only takes a UIColor.

Is it possible to either set the default navigation back button image (without manually changing every viewcontroller) or convert an image into a UIColor?

Thank you!

UPDATE: ANSWER IS BELOW

Apparently UIBarButtonItem has a separate function for the backbutton customization. I had to create another image for the back button based off navbar_btn.png and set it using:

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
1

1 Answers

9
votes

Apparently UIBarButtonItem has a separate function for the backbutton customization. I had to create another image for the back button based off navbar_btn.png and set it using:

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];