0
votes

In my app, I have given navigation bar back button colour as red. Both arrow and text works finely with iPhone in all screens. But in iPad it works correctly only for home screen. When I enter inside any of the other view controllers, my navigation back text is in red colour but back button arrow becomes grey colour. Here is my code,

func setup() {
    self.navigationBar.barTintColor = UIColor.blue()
    UINavigationBar.appearance().titleTextAttributes = [
        NSForegroundColorAttributeName : UIColor.white,
        NSFontAttributeName : UIFont(name: "Arial", size: CGFloat(22.0))!
    ]
    self.navigationBar.isTranslucent = true
    UINavigationBar.appearance().tintColor = UIColor.red

//        self.navigationBar.tintColor = UIColor(red: CGFloat(132.0 / 255.0), green: CGFloat(204.0 / 255.0), blue: CGFloat(90.0 / 255.0), alpha: CGFloat(1.0))

    // Draw a bottom border
    let bottomBorderHeight = 3 / UIScreen.main.scale
    let bottomBorder = UIView(frame: CGRect(x: CGFloat(0), y: CGFloat(self.navigationBar.frame.size.height-bottomBorderHeight), width: CGFloat(self.view.bounds.width), height: CGFloat(bottomBorderHeight)))
    bottomBorder.backgroundColor = UIColor(red: CGFloat(0 / 255.0), green: CGFloat(97 / 255.0), blue: CGFloat(56 / 255.0), alpha: CGFloat(1.0))
    self.navigationBar.addSubview(bottomBorder)
}

Tried barTintcolor, appearance, bar style etc..but nothing works. Any idea? TIA.

1
Does tintAdjustmentMode helps?Puttin
when will you call this method func setup() ?KKRocks
try to replace/add these line with yours UINavigationBar.appearance().isTranslucent = true UINavigationBar.appearance().tintColor = UIColor.red UINavigationBar.appearance().barTintColor = UIColor.blueKKRocks
am calling this method in viewDidLoad. And the above code didn't work. Still comes in grey colour.user579911
did you show my answer @user579911Jaydip

1 Answers

0
votes

In Swift 3, try this line to change back button color change

self.navigationController?.navigationBar.tintColor = UIColor.red

I hope it's work for you,