Manuel Escrig Manuel Escrig - 4 months ago 13
iOS Question

MFMailComposeViewController bar background color not changing in iOS7

I'm trying to change the background color of the

MFMailComposeViewController
in iOS7 but I cannot make it work.

I'm using the following snipped:

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

if([picker.navigationBar respondsToSelector:@selector(barTintColor)]) {
// iOS7
picker.navigationBar.barTintColor = READER_NAVIGATION_BAR_BACKGROUND_COLOR;
// Set back button arrow color
[picker.navigationBar setTintColor:READER_NAVIGATION_BAR_BACK_BUTTON_ARROW_COLOR];

// Set Navigation Bar Title Color
[picker.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:READER_NAVIGATION_BAR_TITLE_NORMAL_FONT_COLOR forKey:UITextAttributeTextColor]];

// Set back button color
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:READER_NAVIGATION_BAR_BUTTONS_FONT_COLOR, UITextAttributeTextColor,nil] forState:UIControlStateNormal];

}


Does anybody knows how to change the bakcground color of the
MFMailComposeViewController
in iOS7?

Answer

try this. worked for me.

MFMailComposeViewController* myailViewController = [[MFMailComposeViewController alloc] init];
// set other attributes of mailcomposer here.
myMailViewController.mailComposeDelegate = self;

[myMailViewController.navigationBar setTintColor:[UIColor whiteColor]];

[self presentViewController:myMmailViewController animated:YES completion:nil];