我正在设置导航栏和状态栏。
static func setParamsBars(){
let bounds = UIScreen.main.bounds
UIApplication.shared.statusBarView?.backgroundColor = .clear
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white, NSFontAttributeName: UIFont(name: "SFUIDisplay-Regular", size: 18)!]
let imagebar : UIImage = UIImage(color: UIColor(red: 136.0/255.0, green: 136.0/255.0, blue: 136.0/255.0, alpha: 0.8), size: CGSize(width: bounds.size.width, height: 84))!
UINavigationBar.appearance().setBackgroundImage(imagebar, for: .default)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().isTranslucent = true
}
并在didFinishLaunchingWithOptions
然后我添加了以下代码。确保:
func applicationDidBecomeActive(_ application: UIApplication) {
AppEventsLogger.activate(application)
print("applicationDidBecomeActive")
//AppDelegate.setParamsBars()
//UINavigationBar.appearance().clipsToBounds = false
//UINavigationBar.appearance().isTranslucent = true
UIApplication.shared.statusBarView?.backgroundColor = .clear
}
答案 0 :(得分:0)
扩展名UIApplication { var statusBarView:UIView? { 返回值(forKey:" statusBar")为?的UIView } }
UIApplication.shared.statusBarView?.backgroundColor = .red