UINavigationBar 在 scroll/swipe 上隐藏后不会再次显示
UINavigationBar won't show again after hiding on scroll/swipe
正如标题所说,navigationBar在滚动后隐藏不显示。我尝试在 xCode 中以及以编程方式设置它。无论哪种方式,问题仍然存在。
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
navigationController?.hidesBarsOnSwipe = true
}
这是隐藏导航栏后的样子。请注意,状态栏颜色也从白色变为黑色。
在 viewDidLoad 中我有:
//MARK: navigation bar styles
self.navigationController?.navigationBar.backgroundColor = UIColor.init(red: 26/255, green: 24/255, blue: 24/255, alpha: 1)
self.navigationController?.navigationBar.clipsToBounds = true
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIFont(name:"GillSans", size: 20)!]
有没有人对此有好的解决方案?预先感谢您的帮助!
试试这个代码:
注意: 当您将导航栏背景设置为接近黑色时。您必须将状态栏内容更改为浅色。
//用下面的代码更新你的plist
View controller-based status bar appearance = NO
在你的ViewController中:
title = "Some Title"
navigationController?.navigationBar.barTintColor = UIColor(red: 26/255, green: 24/255, blue: 24/255, alpha: 1)
navigationController?.navigationBar.tintColor = UIColor.white
//Title Colour and Font
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white, NSFontAttributeName:UIFont(name:"Arial", size: 20)!]
navigationController?.navigationBar.clipsToBounds = false
UIApplication.shared.statusBarStyle = .lightContent
}
override func viewDidAppear(_ animated: Bool) {
navigationController?.hidesBarsOnSwipe = true
}
输出:
正如标题所说,navigationBar在滚动后隐藏不显示。我尝试在 xCode 中以及以编程方式设置它。无论哪种方式,问题仍然存在。
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
navigationController?.hidesBarsOnSwipe = true
}
这是隐藏导航栏后的样子。请注意,状态栏颜色也从白色变为黑色。
在 viewDidLoad 中我有:
//MARK: navigation bar styles
self.navigationController?.navigationBar.backgroundColor = UIColor.init(red: 26/255, green: 24/255, blue: 24/255, alpha: 1)
self.navigationController?.navigationBar.clipsToBounds = true
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName:UIFont(name:"GillSans", size: 20)!]
有没有人对此有好的解决方案?预先感谢您的帮助!
试试这个代码:
注意: 当您将导航栏背景设置为接近黑色时。您必须将状态栏内容更改为浅色。
//用下面的代码更新你的plist
View controller-based status bar appearance = NO
在你的ViewController中:
title = "Some Title"
navigationController?.navigationBar.barTintColor = UIColor(red: 26/255, green: 24/255, blue: 24/255, alpha: 1)
navigationController?.navigationBar.tintColor = UIColor.white
//Title Colour and Font
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.white, NSFontAttributeName:UIFont(name:"Arial", size: 20)!]
navigationController?.navigationBar.clipsToBounds = false
UIApplication.shared.statusBarStyle = .lightContent
}
override func viewDidAppear(_ animated: Bool) {
navigationController?.hidesBarsOnSwipe = true
}
输出: