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

iOS

help please

Using the appearance variable, set the tint color property to white color.

i tried this:

UINavigationBar *appearance = [barTintColor = whiteColor];

didnt work

1 Answer

Hi Lyric,

What you currently have is invalid code as an equals symbol is illegal inside of the [] brackets, instead what you what to be doing is targeting the UINavigationBar directly, grabbing it's appearance property and then setting the tint colour using an UIColor object.

[[UINavigationBar appearance] setBarTintColor: [UIColor whiteColor]];

This is for iOS 7+ only, if you're working with iOS 6 or below you will need to use the below.

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
  // iOS <= 6
  [[UINavigationBar appearance] setTintColor: [UIColor whiteColor]];
} else {
  // iOS >= 7
  [[UINavigationBar appearance] setBarTintColor: [UIColor whiteColor]];
}

Ah, the quiz is slightly different so what you want to do is capture the appearance property of UINavigationBar and then use it to set the tintColor property.

UINavigationBar *appearance = [UINavigationBar appearance];
appearance.tintColor = [UIColor whiteColor];