gpt4 book ai didi

swift - View Controller 中没有显示导航栏或任何导航栏属性

转载 作者:行者123 更新时间:2023-11-28 10:40:08 24 4
gpt4 key购买 nike

我有一个 View Controller ,我想要一个带有标题的导航栏和标题右侧的按钮。但由于某种原因,导航栏没有显示。

在我添加的应用委托(delegate)中:

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

在 View Controller 的 viewDidLoad 中,我想要导航栏,这是我的代码:

override func viewDidLoad() {
super.viewDidLoad()
let dummyViewController = UIViewController()
dummyViewController.view.backgroundColor = .white
dummyViewController.navigationItem.title = "TEST"
navigationController?.navigationBar.tintColor = .white

为什么没有导航栏,为什么我不能添加带按钮的标题?欢迎任何帮助谢谢。

最佳答案

我曾经遇到过与深色 UINavigationBar 相同的问题。尝试在您的 viewDidLoad 中添加这一行:

self.navigationController?.navigationBar.barStyle = .black

这解决了我的问题。让我知道是否有帮助。

关于swift - View Controller 中没有显示导航栏或任何导航栏属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51029127/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com