简体   繁体   中英

ios 11 issue in MFMailComposeViewController's navigation bar

I used below code to present a MFMailViewController. Everything worked perfectly until ios 11 release.

                let mailViewController = MFMailComposeViewController()
                mailViewController.mailComposeDelegate = self               
                mailViewController.setToRecipients(nil)
                mailViewController.setSubject("Subject")
                mailViewController.navigationBar.tintColor = UIColor.green
                UINavigationBar.appearance().isTranslucent = false
                self.present(mailViewController, animated: true, completion:  nil)

No matter what code I use, nothing is working. I am able to present a controller , but navigation bar tint color is not changing. This issue is only with ios 11. I have set overall app navigation bar tint color to white. Hence in controller I get white tint color not green.

I finally found what was wrong. I globally modified UIBarButton in one of the file.

UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.theme, NSFontAttributeName : UIFont.regularAppFontOfSize(0.0)], for: UIControlState.normal)

Even though I used mailViewController.navigationBar.tintColor = UIColor.green , because of global modification , it didn't have any effect.

But what's surprising is, there was no problem in ios 10 and below, but in ios 11.

If any one know the reason, its appreciated.

I'm presenting this function and it's looking fine to me on iOS 11.

override func viewDidLoad() {
    super.viewDidLoad()

    self.present(self.configuredMailComposeViewController(), animated: true, completion: nil)
}

func configuredMailComposeViewController() -> MFMailComposeViewController {
    let mailComposeViewController = MFMailComposeViewController()
    mailComposeViewController.mailComposeDelegate = self
    mailComposeViewController.setSubject("Your subject and stuff like that")

    let nav = self.navigationController?.navigationBar
    nav?.barStyle = UIBarStyle.default
    nav?.tintColor = UIColor.green
    nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.green]

    return mailComposeViewController
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM