【发布时间】:2017-12-13 23:06:36
【问题描述】:
我无法让状态栏以白色显示时钟电池等。
我读了很多关于堆栈溢出的类似问题,但大多数都是旧的并且不是用 swift 编写的。我能找到的最新答案建议override func preferredStatusBarStyle 不再是一个函数。我尝试了以下方法,但它不起作用。
import Foundation
import UIKit
import MessageUI
class ContactUsViewController: MFMailComposeViewController {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func loadView() {
super.loadView()
}
override func viewDidLoad() {
print("mail viewDidLoad()")
self.setNeedsStatusBarAppearanceUpdate()
}
}
我调用视图控制器使用。
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
return
}
self.timeSlider.removeFromSuperview()
let contactVC = ContactUsViewController()// MFMailComposeViewController()
contactVC.navigationBar.tintColor = UIColor.white
contactVC.mailComposeDelegate = self
// Configure the fields of the interface.
contactVC.setToRecipients(["support@example.com"])
contactVC.setSubject("Your subject here")
contactVC.setMessageBody("Enter message about bugs, problems, ideas how to make the app better etc.", isHTML: false)
contactVC.modalPresentationCapturesStatusBarAppearance = true
// Present the view controller
self.navigationController?.present(contactVC, animated: true, completion: nil)
视图控制器缺少什么来更改其StatusBarStyle?
【问题讨论】:
-
Swift 2 - UIApplication.sharedApplication().statusBarStyle = .LightContent Swift 3 - UIApplication.shared.statusBarStyle = .lightContent
-
您是否将这个“基于控制器的状态栏外观”添加到应用信息列表中
-
@zombie 是的,我做到了
-
@SagarSnehi 我不太清楚你的评论是什么意思。我已经在我的
AppDelegate中设置了UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent -
@lukasz 检查此链接stackoverflow.com/questions/26956728/…