MFMailComposeViewController in iOS 7 statusbar are black

前端 未结 13 793
不知归路
不知归路 2020-12-04 23:20

i have a feedback button in my ios 7 application with MFMailComposeViewController. After the user click this button the mailcomposer open but the statusbar changed to black.

13条回答
  •  粉色の甜心
    2020-12-05 00:06

    It seems that initializing the MFMailComposeViewController UIApplication.shared.statusBarStyle will change to .default... so, saving the state before and setting it again after presentation solved the problem for me:

        // save the state, otherwise it will be changed
        let sbs = UIApplication.shared.statusBarStyle
    
        let mailComposerVC = MailComposerVC()
        mailComposerVC.navigationBar.barTintColor = UINavigationBar.appearance().barTintColor
        mailComposerVC.navigationBar.tintColor = UINavigationBar.appearance().tintColor
        mailComposerVC.navigationBar.barStyle = UINavigationBar.appearance().barStyle
    
        if MFMailComposeViewController.canSendMail() {
            APP_ROOT_VC?.present(mailComposerVC, animated: true, completion: {
                // reapply the saved state
                UIApplication.shared.statusBarStyle = sbs
            })
        }
    
        public class MailComposerVC: MFMailComposeViewController {
    
            public override var preferredStatusBarStyle: UIStatusBarStyle {
                return UIApplication.shared.statusBarStyle
            }
            public override var childViewControllerForStatusBarStyle : UIViewController? {
                return nil
            }
        }
    

提交回复
热议问题