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

前端 未结 18 2281
星月不相逢
星月不相逢 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条回答
  •  粉色の甜心
    2020-12-02 04:35

    I like Alex's answer. If you want something quick to try out in a ViewController make sure you use

    viewWillAppear()
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        var nav = self.navigationController?.navigationBar
        nav?.barStyle = UIBarStyle.Black
        nav?.tintColor = UIColor.white
        nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orange]
        //nav?.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.orange] // swift 4.2
    }
    

    enter image description here

提交回复
热议问题