ios - 如何在 swift 项目中隐藏与我的导航 Controller 相连的所有 View Controller 的页脚?

标签 ios uinavigationcontroller swift4 footer xcode9

我正在开发使用 Xcode 9 和 swift 4.1 的 swift 项目。我创建了一个导航 View Controller ,然后创建了另一个 View Controller 并附加了那个导航 View Controller 。

所以默认情况下我有页眉和页脚。所以我有两个问题,

  1. 现在我想更改页脚的颜色而不是白色,但是当我为此编写任何代码时它会在页脚后面变小并且我看不到没有白色的任何颜色。如何为页脚添加任何颜色?

  2. 如果我无法为页脚添加颜色,那么我想使用下面的代码隐藏该页脚

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

但是通过这种颜色我只能隐藏页眉而不是页脚。那么我如何使用代码隐藏页脚,所以我创建了我想要的自定义页脚。

如何在 swift 4.1 中解决上述问题?

最佳答案

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

  1. 要么你的导航 Controller 嵌入在 TabBarController 中
  2. 或者您已经取消隐藏导航 Controller 的工具栏。

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

self.tabBarController?.tabBar.isHidden = true

如果您正在使用导航 Controller 的工具栏(默认情况下是隐藏的)。您可以使用以下代码隐藏它:

navigationController?.setToolbarHidden(true, animated: false)

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

navigationController?.toolbar.barTintColor = .black

关于ios - 如何在 swift 项目中隐藏与我的导航 Controller 相连的所有 View Controller 的页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50186656/

相关文章:

ios - 为什么我的 UIScrollView 中的 UIView 不滚动?

ios - UICollectionView View 和约束以使单元格适合

ios - 如何为导航栏设置自定义(RGB)颜色?

ios - 将方法添加到UINavigationBar后退按钮?

swift - xcode 9.0.1/swift 4,没有使用 Objective-C 选择器 'onClick:forEvent:' 声明的方法

ios - 转换为 Swift 3(Swift 和 Firebase 项目)

ios - 导航 Controller 从第二次转换开始显示

swift - 现在 Swift 4 中的 filePrivate 有什么意义?

swift - 使用 Alamofire 将参数转换为 Base64 编码字符串以进行 API 调用

android - 如何遍历dart中的以下循环?