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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.