MFMailComposeViewController NavigationBar not conforming to the appearance protocol

Hello,


I'm trying to display

MFMailComposeViewController
in an app.


if MFMailComposeViewController.canSendMail() {
  let mailComposeViewController = MFMailComposeViewController()
  mailComposeViewController.navigationBar.tintColor = .white
  mailComposeViewController.mailComposeDelegate = self
  mailComposeViewController.setToRecipients(["support@gmail.com"])
  mailComposeViewController.setSubject("Feedback")
  present(mailComposeViewController, animated: true)
} else {
  print("This device is not configured to send email. Please set up an email account.")
}


This is how I set the styles for the navigation bars.


UINavigationBar.appearance().barTintColor = .green
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
  UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
}


In iOS 12, it shows up without an issue. See here.



For iOS 13, I added the following code for setting the styles.


if #available(iOS 13.0, *) {
      let navigationBarAppearance = UINavigationBarAppearance()
      navigationBarAppearance.configureWithOpaqueBackground()
      navigationBarAppearance.backgroundColor = .green
      navigationBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
      navigationBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]

      UINavigationBar.appearance().standardAppearance = navigationBarAppearance
      UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
}


But when I run on a device (iOS 13.2), the colors don't show up. See here.



Is this an iOS bug? Or am I missing something in the appearance setting?


Thanks!

Replies

We see some green line at the top, which seems to be a part of the header.


Should try by setting the transition from Automatic to full screen.


And tell what you get.

That green line is the navigation bar of the view controller before this one. In iOS 13, modal views show up like this. With the previous view controller visible under it.

Can we add toolbar with buttons in MFMailComposeViewController??