私のアプリのステータスバーの背景色を変更するには、具体的に3のUIViewControllers
を透明にし、残りを何かに設定したいと思っています。現在のViewControllerに基づいて背景色StatusBarを変更しますか?
どのビューコントローラが現在のビューコントローラであるかを確認する方法がわかりません。 if/else文でなければなりません。私は私のAppDelegate
でこれを持っている:
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
let appDelegate = UIApplication.shared.delegate as? AppDelegate
if let currentVC = appDelegate?.window?.rootViewController?.getCurrentlyDisplayedVC()
{
if currentVC is LoginVC || currentVC is RegisterVC || currentVC is LostPasswordVC {
UIApplication.shared.statusBarView?.backgroundColor = .clear
} else {
UIApplication.shared.statusBarView?.backgroundColor = Color_Main_Blue
}
}
UIApplication.shared.statusBarStyle = .lightContent
return true
}
私の留守を確認してください。 https://stackoverflow.com/questions/43073623/changing-the-color-of-the-status-bar/43073806#43073806あなたのお役に立てば幸いです! – byJeevan