Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController bar background color not changing in iOS7

Tags:

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?

like image 457
Manuel Escrig Avatar asked Feb 04 '14 08:02

Manuel Escrig


1 Answers

The trick here is to call 'appearance methods' such as

[UINavigationBar appearance].barTintColor = [UIColor whiteColor]; [UINavigationBar appearance].tintColor = [UIColor redColor]; 

BEFORE calling to

[[MFMailComposeViewController alloc] init]; 

This way the color scheme will be applied to the mail composer. It may be returned back to defaults in mailComposeController:didFinishWithResult:

like image 58
SoftDesigner Avatar answered Oct 10 '22 00:10

SoftDesigner