Cannot set bartintcolor on iPhone 6 plus

94 Views Asked by At

So my problem is that I cannot set the bar tint color on an iPhone 6 plus. I can set the bar tint color for all other devices but for the iPhone 6 plus the bar tint won't change. Here is the code for the view controller. Additionally, this VC is being pushed onto the stack by a navigation controller. Any help is majorly appreciated all.

override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.navigationBar.barTintColor = .redColor()
        navigationController?.navigationBar.translucent = false
        navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
        navigationController?.navigationBar.tintColor = UIColor.whiteColor()
    }

This is the only thing that I am doing in the view controller and it doesn't work at all.

1

There are 1 best solutions below

0
WikipediaBrown On

Ok so I solved the issue. For some reason, iPhone 6 plus calls

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    navigationController?.navigationBar.barTintColor = .primaryGrayColor()
    navigationController?.navigationBar.translucent = false
    navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
}

every time a new view controller is pushed onto a navigation stack. This does not happen in the iPhone 5, iPhone 5s, iPhone 6 or the iPhone 7.