[[UINavigationBar appearance] setTitleTextAttributes: @{ NSForegroundColorAttributeName: navigationBarFontColor, NSFontAttributeName: navigationBarFont }];

I set all the button colors in my app via the above appearance proxy. It changes the color of the text for icons like "+" and back buttons like "< Home".

However, when I pop up a MFMailComposeViewController, the Cancel and Send button are in default iOS blue, and not in the color I've chosen like the rest of my application. Why is this?

        if ([MFMailComposeViewController canSendMail])
        {
            MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
            mailController.mailComposeDelegate = self;

            [mailController setSubject:REPORTMISSING_SUBJECT];
            [mailController setToRecipients:[NSArray arrayWithObject:REPORTMISSING_RECEIPIENT]];

            [self presentViewController:mailController animated:YES completion:nil];
        }
1

There are 1 answers

0
Artal On

As far as I know, the setTitleTextAttributes method can only change the title properties of the navigation bar and will not affect the buttons. That said, if you still want to use this method to customize the title, try calling it right before creating your MFMailComposeViewController instance and it should work.

To change the cancel/send button colors you can use the tintColor property:

mailController.view.tintColor = navigationBarFontColor;

Or, you can use the appearance proxy for UIBarButtonItem. That should work too and will also let you change the font (again, you'll need to call it right before creating and presenting the mail composer):

[[UIBarButtonItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName: navigationBarFontColor, NSFontAttributeName: navigationBarFont } forState:UIControlStateNormal];