【问题标题】:Change color and back button title of Navigation Bar from Swift 3 code从 Swift 3 代码更改导航栏的颜色和后退按钮标题
【发布时间】:2016-12-04 13:09:42
【问题描述】:

仅使用代码制作我的应用的 UI。 找不到如何自定义几个元素: 1. 按钮“返回”现在看起来像:

它应该看起来像:

那么,我怎样才能摆脱按钮标题中的“返回”文本,保留“

【问题讨论】:

    标签: uinavigationcontroller swift3 uinavigationbar uinavigationitem


    【解决方案1】:

    试试

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

    【讨论】:

    • 成功了!谢谢!如何摆脱按钮标题中的“返回”文本?
    • @zzheads 在 vi​​ewDidLoad 内部,你必须简单调用... navigationItem.leftBarButtonItem = UIBarButtonItem(image: "your_image_name", style: .normal, target: self, action: #selector( handleBack)) 然后您必须创建一个名为“func handleBack”的函数,并在其中简单地调用它来关闭视图,就像后退按钮一样:dismiss(animated: true, completion: nil)
    【解决方案2】:

    试试:

    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
    }
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-04-28
          • 1970-01-01
          • 1970-01-01
          • 2021-11-16
          • 2014-04-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多