【问题标题】:Set custom UINavigationBar class from Interface Builder从 Interface Builder 设置自定义 UINavigationBar 类
【发布时间】:2018-08-22 02:08:29
【问题描述】:

我想要一个自定义 UINavigationController 子类,它有一个自定义 UINavigationBar 类作为它的导航栏,但它需要是可以从情节提要中设置的东西。

除了具有 navigationBarClass 作为参数的 init 函数之外,我看不到任何其他方法可以在 UINavigationController 上设置 navigationBarClass(即使是子类化),但这将忽略 nib 属性和 rootViewController(和崩溃)。

class CustomNavigationController : UINavigationController {
  override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
      //This clearly doesn't work because it will not account for the styling, 
      // attributes, and rootViewController applied from the nib
      super.init(navigationBarClass: CustomNavigationBar, toolbarClass: nil)

  }
}

有没有办法解决这个问题?或者我可以假设没有办法在情节提要中使用自定义导航栏类​​?

【问题讨论】:

  • 您找到解决方案了吗?

标签: ios uinavigationcontroller storyboard uikit uinavigationbar


【解决方案1】:

在 IB 中,打开导航控制器,然后在左侧列表中选择“导航栏”:

在右侧的检查器中,更改自定义类:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-16
    • 2010-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多