一驱负、兩種方式 管理 狀態(tài)欄
由 info.plist 中的 UIViewControllerBasedStatusBarAppearance 這個配置決定
如果設(shè)置為YES邑雅,表示由 ViewController 來管理
如果設(shè)置為NO片橡,表示由 UIApplication 來管理
這項配置默認是沒有的,系統(tǒng)默認由 UIApplication 管理
如果想讓 ViewController 來管理淮野,需要手動添加捧书,并將值設(shè)置為YES
info.plist
1、由 UIApplication 對象管理骤星,設(shè)置一次全局改變
/**
設(shè)置狀態(tài)欄是否隱藏
*/
UIApplication.shared.isStatusBarHidden = true
/**
設(shè)置狀態(tài)欄顏色
默認黑色经瓷,lightContent(白色)、default(黑色)
*/
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
或者直接在如圖下設(shè)置
狀態(tài)欄設(shè)置
2洞难、在 ViewController 中管理舆吮,只在當前控制器作用
/**
設(shè)置狀態(tài)欄是否隱藏
*/
override func prefersStatusBarHidden() -> Bool {
return true;
}
/**
設(shè)置狀態(tài)欄顏色
默認黑色,lightContent(白色)队贱、default(黑色)
*/
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent;
}