我有6个视图控制器,并且正在使用UiTabbar视图。因此,在主屏幕中,选项卡中显示4个ViewController的数量,OS创建另一个ViewController,并将其命名为more。
点击更多,它向我展示了UiTableView内部的视图控制器2。当我单击它们时,它会打开我的viewcontroller,其顶部的Navigation控制器带有标记为More的后退按钮
我想要的内容:在这里您可以看到“返回”按钮仅显示更多内容,我只想显示“返回”按钮,并希望居中 标题,标签为“要约”,白色文本
更新1:
在ViewWillDisplay()中调用此方法
func setUpNavBar(title: String,backBtn : String) -> Void {
let backButton = UIBarButtonItem(title: " ",style: .plain,target: nil,action: nil)
navigationItem.backBarButtonItem = backButton
navigationController?.navigationBar.tintColor = UIColor.white
let titleStr = title
self.navigationItem.title = titleStr
self.navigationItem.titleView?.backgroundColor = UIColor.red
let titleLabel = UILabel()
titleLabel.textColor = .white
titleLabel.text = titleStr
self.navigationItem.titleView = titleLabel
self.navigationController?.navigationBar.barTintColor = CommonUtils.hexStringToUIColor(hex: AppColor.colorTwentyScaleDarkerOfColorPrimaryDark)
if var textAttributes = navigationController?.navigationBar.titleTextAttributes {
textAttributes[NSAttributedString.Key.foregroundColor] = UIColor.white
navigationController?.navigationBar.titleTextAttributes = textAttributes
}
}