2016-11-07 105 views
0

如标题所示,navigationBar在滚动时隐藏后不会显示。我尝试在xCode中以编程方式设置它。无论哪种方式,问题仍然存在。 enter image description hereUINavigationBar在滚动/滑动后隐藏后不会再显示

override func viewDidAppear(animated: Bool) { 
     super.viewDidAppear(animated) 

     navigationController?.hidesBarsOnSwipe = true 
    } 

这里是什么样子隐藏导航栏后。请注意,状态栏颜色也从白色变为黑色。

enter image description here

在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)!] 

有谁有这个好的解决办法?预先感谢您的帮助!

+0

你用另一种navigationController的代码? – KKRocks

+0

你可以发布你的viewDidLoad吗? – Joe

+0

@KKRocks我不这么认为。我试图使用self.navigationController,它仍然是相同的 – WoShiNiBaBa

回答

0

试试这个代码:

注:当你设置你的导航栏的背景接近黑色。你必须改变你的状态栏内容。与

//更新您的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 

    } 

输出:

enter image description here

+0

更新plist文件的原因是什么?我已经通过使用以下代码使状态栏变白://更改状态栏样式 override func preferredStatusBarStyle() - > UIStatusBarStyle { return UIStatusBarStyle.LightContent }滚动后导航条仍不会出现。 – WoShiNiBaBa