swiftuinavigationcontrolleruistatusbar

Can not override the preferredStatusBarStyle


In dark mode style, the status bar disappear cause of dark color.

I added the:

 override var preferredStatusBarStyle: UIStatusBarStyle {
            return .lightContent
        }

but the problem is, when I add the method in "viewDidLoad" I get the error:

override can only be specified in class member

any idea how to resolve this?


Solution

  • I am going to answer the question here, maybe it can help someone else:

    After hours checking my codes, I found out that I have rootViewController which I used as a authentication then after the authentication user pass to TabbarViewController... which is not rootViewController, I added the:

    preferredStatusBarStyle

    To my rootViewController and it works.

    View controller-based status bar appearance should be YES