解答:
I / Open Info.plist文件 - >添加新行:查看基于控制器的状态栏外观 - >设置为[是]
II /打开yourViewController.swift文件并插入:
override func prefersStatusBarHidden() -> Bool {
// Return false -> Show statusBar
return false
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
// Change status background color
let statusBar: UIView = UIApplication.sharedApplication().valueForKey("statusBar") as! UIView
if statusBar.respondsToSelector(Selector("setBackgroundColor:")) {
statusBar.backgroundColor = UIColor.redColor()
}
// Change textColor -> While(LightContent)
return UIStatusBarStyle.LightContent
}