2017-08-08 11 views
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 
} 

と私はアプリケーションに戻るときにステータスバーが色 enter image description here

を変更 enter image description here

電話番号に電話をかけenter image description here

私の最初の画面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 

} 

答えて

0

延長のUIApplication { するvar statusBarView:UIViewのを? { 戻り値(forKey: "statusBar")は? UIViewの }}

UIApplication.shared.statusBarView?.backgroundColor = .red

関連する問題