From b70cbfd9f6b51d8d92d717f27e30864564f6505f Mon Sep 17 00:00:00 2001 From: "xiaoyou.qu" Date: Mon, 5 Feb 2024 11:09:47 +0800 Subject: [PATCH] =?UTF-8?q?Demo=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Example/XYNav/Base.lproj/Main.storyboard | 16 ++++----- XYNav/Example/XYNav/GreenViewController.swift | 34 +++++++++++++++++++ XYNav/Example/XYNav/Info.plist | 2 ++ XYNav/Example/XYNav/ViewController.swift | 25 ++++++++++++++ 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/XYNav/Example/XYNav/Base.lproj/Main.storyboard b/XYNav/Example/XYNav/Base.lproj/Main.storyboard index 52863f7..e9b9ee3 100644 --- a/XYNav/Example/XYNav/Base.lproj/Main.storyboard +++ b/XYNav/Example/XYNav/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -71,10 +71,10 @@ - + - + @@ -95,7 +95,7 @@ - + @@ -109,11 +109,11 @@ - + - + @@ -204,7 +204,7 @@ - + diff --git a/XYNav/Example/XYNav/GreenViewController.swift b/XYNav/Example/XYNav/GreenViewController.swift index c3e348c..abd0ed8 100644 --- a/XYNav/Example/XYNav/GreenViewController.swift +++ b/XYNav/Example/XYNav/GreenViewController.swift @@ -10,6 +10,40 @@ import UIKit class GreenViewController: BaseViewController { var hideNavBar = false + +// override var preferredStatusBarStyle: UIStatusBarStyle { +// if #available(iOS 13.0, *) { +// return UIStatusBarStyle.darkContent +// } else { +// // Fallback on earlier versions +// return UIStatusBarStyle.default +// } +// } +// + override var prefersStatusBarHidden: Bool { + true + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + // UIApplication.shared.setStatusBarHidden(true, with: .fade) +// UIApplication.shared.isStatusBarHidden = true + + if #available(iOS 13.0, *) { + let scenes = UIApplication.shared.connectedScenes + for scene in scenes { + if let wins = scene as? UIWindowScene { + let frame = wins.statusBarManager?.statusBarFrame ?? .zero + let hidden = wins.statusBarManager?.isStatusBarHidden ?? true + let style = wins.statusBarManager?.statusBarStyle ?? .lightContent + print("\(frame)\n\(hidden)\n\(style)") + } + } + } else { + // Fallback on earlier versions + } + } override func viewDidLoad() { super.viewDidLoad() diff --git a/XYNav/Example/XYNav/Info.plist b/XYNav/Example/XYNav/Info.plist index eb18faa..a3c4b85 100644 --- a/XYNav/Example/XYNav/Info.plist +++ b/XYNav/Example/XYNav/Info.plist @@ -30,6 +30,8 @@ armv7 + UIStatusBarStyle + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait diff --git a/XYNav/Example/XYNav/ViewController.swift b/XYNav/Example/XYNav/ViewController.swift index 365fb93..663cb2c 100644 --- a/XYNav/Example/XYNav/ViewController.swift +++ b/XYNav/Example/XYNav/ViewController.swift @@ -79,6 +79,29 @@ class ViewController: BaseViewController { self.title = "RootVC - \(index)" self.view.addSubview(tableView) } + + + override var preferredStatusBarStyle: UIStatusBarStyle { + if #available(iOS 13.0, *) { + return UIStatusBarStyle.darkContent + } else { + // Fallback on earlier versions + return UIStatusBarStyle.default + } + } + + override var prefersStatusBarHidden: Bool { + true + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + +// UIApplication.shared.setStatusBarHidden(true, with: .fade) + UIApplication.shared.isStatusBarHidden = true + } + + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // navigationBar 需要在此函数中才能被加载到, @@ -87,6 +110,8 @@ class ViewController: BaseViewController { // self.tabBarController?.tabBar.isTranslucent = false self.navigationController?.navigationBar.barTintColor = UIColor.xy_getColor(hex: 0x006aff) + + // tabbar 透明 tabBarController?.tabBar.isTranslucent = true