我正在尝试将默认的backBarButtonItem颜色更改为白色,
我的代码如下所示
self.navigationItem.backBarButtonItem?.tintColor = UIColor.whiteColor()
但它不适合我,任何想法?
答案 0 :(得分:6)
试试这个:
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
答案 1 :(得分:0)
尝试一下:
self.navigationController?.navigationItem.backBarButtonItem?.tintColor = UIColor.red
答案 2 :(得分:0)
如果要更改backBarButton,请执行以下操作:
override func viewDidLoad() {
super.viewDidLoad()
let newBackButton = UIBarButtonItem(title: "B",
style: UIBarButtonItem.Style.plain, target: self, action: "backAction")
navigationController?.navigationBar.topItem?.backBarButtonItem = newBackButton
newBackButton.tintColor = .red
// Do any additional setup after loading the view.
}
func backAction() -> Void {
self.navigationController?.popViewController(animated: true)
}