简体   繁体   English

为导航栏后退按钮和后退按钮文本设置不同的颜色

[英]set different color for navigation bar back button and back button text

I am trying to have different colors for back button text and back button.我正在尝试为后退按钮文本和后退按钮设置不同的 colors。

If I set the global tint, it changes color for both.如果我设置全局色调,它会改变两者的颜色。 Is there a way I could have different color for both?有没有办法我可以为两者设置不同的颜色?

As i understand you just want to change back button color and back button in different screen different.Not globally So you can do this several way.Here is simplest way.据我了解,您只想更改不同屏幕中的后退按钮颜色和后退按钮。不是全局的所以您可以通过多种方式执行此操作。这是最简单的方法。

Just change navigation tint color of its viewDidLoad or viewWillApper method.只需更改其 viewDidLoad 或 viewWillApper 方法的导航色调颜色即可。

ViewController One:视图控制器一:

override func viewDidLoad() {
        super.viewDidLoad()
   self.navigationController?.navigationBar.tintColor = UIColor.green

    }

ViewConbtroller Two:视图控制器二:

override func viewDidLoad() {
        super.viewDidLoad()
   self.navigationController?.navigationBar.tintColor = UIColor.red

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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