Changing MFMailComposeViewController's toolbar color

Viewed 16724

I'm using a tinted navigation bar and a tinted global UIToolbar in my iPhone app. In my info view, I have a button which opens a MFMailComposeViewController, and the toolbar at the top of that view (with the "cancel" and "send" button) is still blue. I'm calling the MFMailComposeViewController like this:

-(void)displayMailSheet
{

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"..."];

    NSArray *toRecipients = [NSArray arrayWithObject:@"..."]; 

    [picker setToRecipients:toRecipients];

    [self presentModalViewController:picker animated:YES];
    [picker release];

}

Is it possible to change the color of that view's toolbar? If it is possible, how can I do this?

6 Answers

you can do it globally from appdelegate

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationbar-background.png"] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault]; // MFMailComposeViewController's navigationBar backgroundcolor 

NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:textTitleOptions];//MFMailComposeViewController's navigationBar text color 

Just want to emphasize that the above post about Apple rejecting your application is an old post. Here is a quote from the current MFMailComposeViewController documentation...

Important: The view hierarchy of this class is private and you must not modify it. You can, however, customize the appearance of an instance by using the UIAppearance protocol.

From the official MFMailComposeViewController Class reference:

Important: The mail composition interface itself is not customizable and must not be modified by your application. [...]

I think it would be a better choice presenting the default mail composition interface without any changes. Otherwise Apple may reject your application.

Let's ask here if someone had an experience in this way.

Related