ios 11 issue in MFMailComposeViewController's navigation bar

回眸只為那壹抹淺笑 提交于 2019-12-10 11:34:49

问题


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.


回答1:


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.




回答2:


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
}


来源:https://stackoverflow.com/questions/47483682/ios-11-issue-in-mfmailcomposeviewcontrollers-navigation-bar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!