NavigationBar bar, tint, and title text color in iOS 8

前端 未结 18 2292
星月不相逢
星月不相逢 2020-12-02 04:08

The background text in the status bar is still black. How do I change the color to white?

// io8, swift, Xcode 6.0.1 
override func viewDidLoad() {
    super         


        
18条回答
  •  萌比男神i
    2020-12-02 04:37

    To change the color universally, this code should sit in the NavigationController's viewDidLoad function:

    class NavigationController: UINavigationController, UIViewControllerTransitioningDelegate {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Status bar white font
            self.navigationBar.barStyle = UIBarStyle.Black
            self.navigationBar.tintColor = UIColor.whiteColor()
        }
    }
    

    To change it per ViewController you would have to reference the NavigationController from the ViewController and write similar lines in that ViewController's viewWillAppear function.

提交回复
热议问题