Reputation: 6229
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?
Upvotes: 2
Views: 490
Reputation: 11537
In IB, open your Navigation Controller, then in the list on the left, select the "Navigation Bar":
In the inspector on the right, change the Custom Class:
Upvotes: 2