preferredStatusBarStyle .lightContent doesn't work with Navigation Controller. I have tried this method below
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
This is my first time to face this kind of issue. This code works in my Previous apps.
I even change this in my target:
I think you forget to change statusbar style in info.plist
Change in info.plist the row View controller-based status bar appearance and set it to YES
and in Your ViewController:
override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent }
No other code is required
Make sure that in your Info.plist file you have View controller-based status bar appearance
set to NO
. It would also be helpful to check that you don't programatically set the status bar to a different color in a view controller by accident. If you're using the above function, do you call self.setNeedsStatusBarAppearanceUpdate
? But you shouldn't need to write any code at all if you set Light
as the value in your project settings and NO
in your plist file.
Another option that has worked for me in the past is in your AppDelegate file, in the didFinishLaunchingWithOptions
function do this:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .lightContent
return true
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.