iosemailcontact-list

Changing text color UINavigationBar


Hi i'm working on an iOS project that uses the MFMailComposeViewController to send out an email.

I changed the title bar to use an image

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"project_headerbg"] forBarMetrics:UIBarMetricsDefault];

but now when I click on the '+' button next to CC I can't read the text "Choose a contact to mail" in the header very well and was wondering if there was a way to change the color of that text?

Thanks


Solution

  • This question has nothing to do with using the MFMailComposeViewController. If you wish to customize the appearance of a UINavigationBar, then you may need to set more properties than just the background image. You should also setup the titleTextAttributes.

    // Use whatever color is appropriate
    NSDictionary *attributes = @{ UITextAttributeTextColor: [UIColor blueColor] };
    [[UINavigationBar appearance] setTitleTextAttributes:attributes];
    

    There are other attributes such as the font and shadow colors. Feel free to set the ones you need.