0
我正在設置導航欄和狀態欄。當我從我的應用程序調用時更改狀態欄的顏色
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
然後我加了th e下面的代碼。保證:
func applicationDidBecomeActive(_ application: UIApplication) {
AppEventsLogger.activate(application)
print("applicationDidBecomeActive")
//AppDelegate.setParamsBars()
//UINavigationBar.appearance().clipsToBounds = false
//UINavigationBar.appearance().isTranslucent = true
UIApplication.shared.statusBarView?.backgroundColor = .clear
}