【发布时间】:2018-06-25 17:43:13
【问题描述】:
我有一个视图控制器,我想要一个带有标题和标题右侧按钮的导航栏。但由于某种原因,导航栏没有显示出来。
在我添加的应用委托中:
window?.rootViewController =
UINavigationController(rootViewController: MessagesController())
UITableViewCell.appearance().textLabel?.textColor = UIColor.white;
UITableViewCell.appearance().backgroundColor = UIColor.clear
UIApplication.shared.statusBarStyle = .lightContent
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
UINavigationBar.appearance().barTintColor = UIColor(red:0.13, green:0.15, blue:0.18, alpha:1.0)
UIApplication.shared.isStatusBarHidden = false
在视图控制器的 viewDidLoad 中,我想要导航栏,这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
let dummyViewController = UIViewController()
dummyViewController.view.backgroundColor = .white
dummyViewController.navigationItem.title = "TEST"
navigationController?.navigationBar.tintColor = .white
为什么没有导航栏,为什么我不能给它添加带有按钮的标题?欢迎任何帮助谢谢。
【问题讨论】:
标签: swift xcode uinavigationcontroller uinavigationbar