简体   繁体   中英

Navigation bar back button colour not working in iPad

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.

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,

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM