Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Another tricky one...changing button color in navigation bar

I am referring to this code challenge :http://teamtreehouse.com/library/styling-the-navigation-bar Here's the question : Now we want to change the color of the text of our navigation bar buttons to white. Use the appearance proxy to change the color using [UIColor whiteColor].

And now my code which needs to be debugged :

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Customize the nav bar
    UIImage *backgroundImage = [UIImage imageNamed:@"navBarBackground"];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
   [[UINavigationBar appearance] setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBarButtonItemColor:[UIColor whiteColor]];


    return YES;
}

@end

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

This is a tricky one that is on my list of challenges to revise. To change the text color of a button in the navigation bar you can use the setTintColor method.

Thanks ! I eventually figured it out but took me a few hours of hair pulling ! :-)