如何在 MFMailComposeViewController 中将状态栏更改为白色?
How to change status bar to White in MFMailComposeViewController?
图片如下图
在我的应用程序中,添加了电子邮件提示,但是状态栏现在是黑色,如何将其更改为白色样式[=21] =]?
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)
}
在视图中会出现:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
self.navigationController.navigationBar.translucent = false
self.navigationController.navigationBar.opaque = false
self.navigationController.navigationBar.barTintColor = UIColor.blueColor()}
要更改整个应用程序的状态栏颜色,请在 app delegate 中编写这行代码
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
进入您的应用委托 didFinishLoading。
在显示邮件编辑器之前调用此方法,
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
statusBar.backgroundColor = color
}
尝试在完成处理程序中设置 statusBarStyle
而 present
邮件控制器像这样
self.present(composeMail, animated: true, completion:{ () in
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
})
希望它能奏效。
图片如下图
在我的应用程序中,添加了电子邮件提示,但是状态栏现在是黑色,如何将其更改为白色样式[=21] =]?
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)
}
在视图中会出现:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
self.navigationController.navigationBar.translucent = false
self.navigationController.navigationBar.opaque = false
self.navigationController.navigationBar.barTintColor = UIColor.blueColor()}
要更改整个应用程序的状态栏颜色,请在 app delegate 中编写这行代码
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
进入您的应用委托 didFinishLoading。
在显示邮件编辑器之前调用此方法,
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
statusBar.backgroundColor = color
}
尝试在完成处理程序中设置 statusBarStyle
而 present
邮件控制器像这样
self.present(composeMail, animated: true, completion:{ () in
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
})
希望它能奏效。