从Swift 3代码更改导航栏的颜色和后退按钮标题

时间:2016-12-04 13:09:43

标签: uinavigationcontroller swift3 uinavigationbar uinavigationitem

仅使用代码制作我的应用的UI。 无法找到自定义情侣元素的方式: 1.按钮'返回'现在它看起来像:

enter image description here

它看起来应该是:

enter image description here

那么,我怎么能摆脱' Back'按钮标题中的文字,保持'<'系统图标在那里?以及如何更改后退按钮和导航栏标题的颜色?

4 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:0)

尝试:

override func viewDidLoad(){
    //any other initial stuffs

    //for the bar
    navigationController?.navigationBar.tintColor = UIColor.black
    //for the button
    navigationController?.navigationBar.backItem?.titleView?.tintColor = UIColor.white
}

答案 2 :(得分:0)

按照xcode的说明进行操作。你可以轻松地做到这一点。我还在图像上做了标记。选择1.选择标准编辑器,2。显示文件检查器3设置全局Ting

From your Xcode you can do this

答案 3 :(得分:0)

使用 XCode 12.3 可以使用以下方法更改标题颜色和返回按钮。

Change Title Color

Change Back Button Color