Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change navigation button color in MFMailComposerViewController on iOS 7

I'm trying to change the text color for navigation buttons in a MFMailComposerViewController but it doesn't work like on iOS 6. In iOS 6 it worked with UIAppearance like this:

// Navigation button
UIBarButtonItem *barButton = [UIBarButtonItem appearance];
NSDictionary *barButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor redColor]};
NSDictionary *disabledBarButtonTitleTextAttributes = @{UITextAttributeTextColor: [UIColor grayColor]};

[barButton setTitleTextAttributes:barButtonTitleTextAttributes forState:UIControlStateNormal];
[barButton setTitleTextAttributes:disabledBarButtonTitleTextAttributes forState:UIControlStateDisabled];
[barButton setBackgroundImage:[[UIImage imageNamed:@"btn_appearance"] stretchableImageWithLeftCapWidth:6 topCapHeight:0] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

But this doesn't work on iOS 7 and looks always like this: enter image description here

I also tried to set the tintColor attribute on the navigationBar but this has no effect either:

navigationBar.tintColor = [UIColor redColor];

Is there anyway to change the navigation button text color in a MFMailComposeViewController on iOS 7?

like image 753
OemerA Avatar asked Oct 12 '13 11:10

OemerA


1 Answers

I used this and works perfect in iOS7+

MFMailComposeViewController* mailViewController = [[MFMailComposeViewController alloc] init];        
mailViewController.mailComposeDelegate = self;
[mailViewController setToRecipients:@[@"[email protected]"]];

[mailViewController.navigationBar setTintColor:[UIColor orangeColor]];

[self presentViewController:mailViewController animated:YES completion:nil]; 
like image 133
Javi Campaña Avatar answered Oct 12 '22 03:10

Javi Campaña