Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController appearance setTintColor getting lost iOS 7

This question is for Xcode 5 running iOS 7 and is super weird. I am trying to set all the UInavigation and UIBarButtonItem text colors to white.

So in my app launch delegate I set the code as.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIImage *NavigationPortraitBackground = [UIImage imageNamed:@"button_header_blue"];

    // Set the background image all UINavigationBars
    [[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];



    // Set the text appearance for navbar
    [[UINavigationBar appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor whiteColor], UITextAttributeTextColor,
      [UIColor whiteColor], UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"Helvetica Neue" size:21], UITextAttributeFont,
      nil]];


    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];


    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                [UIColor whiteColor],
                                UITextAttributeTextColor,
                                [UIColor whiteColor],
                                UITextAttributeTextShadowColor,
                                nil];

    [[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];

    [[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];

    // Override point for customization after application launch.
    return YES;
}

If I launch "send mail" action twice - first time I see UIBarButton items white. I look at it and hit the Cancel button - second time I see them all of them grayed out and barely visible except for the title. - This is happening in both my iPhone simulator and iPhone running iOS 7.

how can I fix this?

enter image description hereenter image description here

like image 459
Sam B Avatar asked Dec 19 '22 20:12

Sam B


1 Answers

I had to do it this way in order for it to work on iOS 7

if ([MFMailComposeViewController canSendMail])
    {

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

        [mailViewController.navigationBar setTintColor:[UIColor whiteColor]];
        [mailViewController.navigationBar setBarTintColor:[UIColor whiteColor]];

....
like image 71
Sam B Avatar answered May 22 '23 10:05

Sam B