iosswiftstatusbarmessageui

How to change status bar to White in MFMailComposeViewController?


Pic is shown down below.

In my app, a have added an Email Prompt, but the status bar is black now, how can I change it to white style?

if MFMailComposeViewController.canSendMail() {
            let composeMail = MFMailComposeViewController()
            composeMail.mailComposeDelegate = self
            //  configs
            composeMail.setToRecipients(["kylebing@163.com"])
            composeMail.setSubject("【饥荒口袋】反馈")
            composeMail.setMessageBody("问题页面:\n\n\n\n建议:\n", isHTML: false)
            composeMail.navigationBar.tintColor = UIColor.white.withAlphaComponent(0.85) // Mail VC's Button Color
            // TODO: - Change status bar color
            //  show it
            self.present(composeMail, animated: true, completion: nil)
}

Balck Status Bar - NOW


Solution

  • Try to set statusBarStyle in completion handler while present mail controller like this

    self.present(composeMail, animated: true, completion:{ () in
         UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
    })
    

    Hope it will work.