UIStatusBarStyle not working in Swift

前端 未结 11 584
轻奢々
轻奢々 2020-12-22 18:30

I\'m trying to change the Status Bar color in my Swift app to white, but am hitting a brick wall. I have 3 ViewControllers that are each embedded in a NavigationController (

11条回答
  •  梦毁少年i
    2020-12-22 19:16

    Step 1. Add to info.plist View controller-based status bar appearance -> NO

    Step 2. Add code in method where you need to change status bar color:

    UIApplication.shared.statusBarStyle = .lightContent //(or .default)
    setNeedsStatusBarAppearanceUpdate()
    

    Key line of code: setNeedsStatusBarAppearanceUpdate()

提交回复
热议问题