2

I would like to have a custom UINavigationController subclass that has a custom UINavigationBar class as its nav bar, but it needs to be something that can be set from a storyboard.

I don't see any other way to set the navigationBarClass on a UINavigationController (even when subclassed) besides the init function that has a navigationBarClass as a parameter, but this will ignore the nib attributes and rootViewController (and crash).

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)

  }
}

Is there a way around this? Or can I assume there is no way to use a custom navigation bar class inside a storyboard?

rmooney
  • 6,123
  • 3
  • 29
  • 29

1 Answers1

2

In IB, open your Navigation Controller, then in the list on the left, select the "Navigation Bar": Navigation Controller element list

In the inspector on the right, change the Custom Class: Navigation Bar Inspector

Sebastian Roth
  • 11,344
  • 14
  • 61
  • 110