Search code examples
objective-cios7mfmailcomposeviewcontrollertintcolor

Change MFMailComposeViewController's UINavigationBar color in iOS7


I am trying to update my app for iOS7, however I am unable to set the colour of the UINavigationBar at the top of the screen. I have tried the classic approach...

[mailer.navigationBar setTintColor:[UIColor darkGreyColour]];

...however it didn't work. I have also tried calling setBarTintColor instead, however that didn't seem to work either.

Does anyone know if its possible to set the colour and if so how?


Solution

  • I had your same problem when updating my application for iOS 7.
    I solved using this line of code (if you use images):

    [[UINavigationBar appearance] setBackgroundImage:@"myImage" forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];
    

    or this one if you are not using images:

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

    I placed then in AppDelegate, just before returning application:didFinishLaunchingWithOptions:

    Hope this helps!