I want to make a taller navigation bar and I am trying to do this using a subclass of UINavigationBar.
Here is my subclass of UINavigationBar:
import
Here is a simple Swift 3 solution based on minimal subclassing. First subclass UINavigationBar.:
class CustomNavigationBar: UINavigationBar {
override func sizeThatFits(_ size: CGSize) -> CGSize {
let newSize :CGSize = CGSize(width: self.frame.size.width, height: 54)
return newSize
}
}
Create the navigation controller in code and use the initializer that takes your custom navigation bar class.
let nav = UINavigationController(navigationBarClass: CustomNavigationBar.self,
toolbarClass: nil)
All existing behavior for UINavigationBar is preserved and your custom height is adopted.