iosswiftuinavigationbarmfmailcomposeviewcontroller

Changing color of text on send/cancel buttons on MFMailComposeViewController


I'm putting the finishing touches on an app and testing on a physical device. Just as I tought I was crossing the finish line to submit to the App Store, I encountered an issue with the color a MFMailComposeViewController's send and cancel buttons. I've dug through a lot of answers here, but none of them seem to get me over the finish line.

The methods below work to send e-mail, but regardless of what I do, the color of the send/cancel buttons remains the default blue color. Any suggestions to rectify this situation are greatly appreciated.

Thank you!

    @IBAction func sendFeedbackEmail(sender: AnyObject)
    {
          feedbackButton.pop()
          print("sendFeedbackEmail called")
          if MFMailComposeViewController.canSendMail()
          {
               let mailComposeViewController = configuredMailComposeViewController()
               self.present(mailComposeViewController, animated: true, completion: nil)
          } else {
              self.showSendMailErrorAlert()
          }
     }


    
    func configuredMailComposeViewController() -> MFMailComposeViewController
    {
         let mailComposerVC = MFMailComposeViewController()
         mailComposerVC.mailComposeDelegate = self
         mailComposerVC.navigationBar.tintColor = .red
    
         mailComposerVC.navigationBar.isTranslucent = false
         mailComposerVC.navigationBar.barTintColor = .white
         mailComposerVC.setToRecipients(["testing@gmail.com"])
         mailComposerVC.setSubject("Feedback")
    
         return mailComposerVC
    }

Solution

  • Swift 4.0

    mailComposeViewController.navigationBar.tintColor = UIColor.red