首页 > 解决方案 > how do I hide footer of all view controller witch attach with my navigation controller in swift project?

问题描述

I am working on swift project, which uses Xcode 9 and swift 4.1. I created one navigation viewcontroller and then created other view controller and attached with that that navigation viewcontroller.

so I got header and footer by default.so I have a two problems,

  1. Now I want a change a color of footer other than white but when I write any code for that It diminished behind footer and I don't see any color without white.How do I give any color to footer?

  2. If I am not able to give color to footer so I want to hide that footer using bellow code

    override func viewWillAppear(animated: Bool)
    {
       self.navigationController?.navigationBarHidden = true
    }
    

But by this color I am able to hide only header not a footer. so how do I hide footer using code so I created customise footer what I want.

How do I solve above problem in swift 4.1?

标签: iosuinavigationcontrollerswift4footerxcode9

解决方案


我不知道您在这里所说的页脚是什么意思,因为默认情况下,当您将视图控制器嵌入导航控制器时,它不会显示任何页脚。您在那里做两件可能的事情:

  1. 您的导航控制器嵌入在 TabBarController 中
  2. 或者您已取消隐藏导航控制器的工具栏。

现在,如果您使用 TabBarController 作为导航控制器的父级,您可以简单地使用以下代码来隐藏页脚:

self.tabBarController?.tabBar.isHidden = true

如果您使用导航控制器的工具栏(默认情况下隐藏)。您可以使用以下代码来隐藏它:

navigationController?.setToolbarHidden(true, animated: false)

要更改工具栏的颜色,您可以简单地使用:

navigationController?.toolbar.barTintColor = .black

推荐阅读