본문 바로가기
Programming/Swift

[iOS Dev Tip] Status bar color

by Eisen Sophie 2021. 9. 3.

 

whenever you have dark background, you need to set the status bar color as white.

 

In order to make this happen, you can use following function in your vc.

override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }

 

However if your view controller is rooted by navigation controller, this method does not work.

 

Instead you can use this settings.

navigationController?.navigationBar.isHidden = true
navigationController?.navigationBar.barStyle = .black