iosmfmailcomposeviewcontrollermfmailcomposer

Incorrect with MFMailComposer Appearance


I'm working on incorporating sMFMailComposer for sending text messages in my app. Below is my code for creating and displaying the message sharing component:

- (void)shareWithMessages {
    
    if(![MFMessageComposeViewController canSendText]) {
        UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [warningAlert show];
        return;
    }
    
    NSString *message = self.articleTitle;
    message = [message stringByAppendingString:@" "];
    message = [message stringByAppendingString:self.urlString];
    
    MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
    messageController.messageComposeDelegate = self;
    [messageController setBody:message];
        
    // Present message view controller on screen
    [self presentViewController:messageController animated:YES completion:nil];
}

When the sharing composer is shown, the "New Message" text is displayed in white:

enter image description here

I tried setting the tint color like so:

[[messageController navigationBar] setTintColor:[UIColor blackColor ]];

...but that had no effect. Does anyone know why the text is set to white, and therefor unreadable?


Solution

  • Probably somewhere in your code you are changing the [UINavigationBar appearance]. So try setting up the appearance of the UINavigationBar before calling

    shareWithMessage
    

    Maybe one of the following 3 do the trick:

    [[UINavigationBar appearance] setTintColor:[UIColor yourColor]];
    [[UINavigationBar appearance] setBarTintColor:[UIColor yourColor]];
    [[UINavigationBar appearance] setTitleTextAttributes:
         @{NSForegroundColorAttributeName:[UIColor yourColor]}];