title: Setting UINavigationBar Subclass in UINavigationController subclass
body: <p>I have a subclass of <code>UINavigationBar</code> and I want to make a subclass of <code>UINavigationController</code> that uses this <code>UINavigationBar</code> subclass. I know how to set the default <code>UINavigationController</code> to use a custom Navigation Bar</p>
  
  <p><code>let navController = UINavigationController(navigationBarClass: CustomNavigationBar.self, toolbarClass: nil)</code></p>
  
  <p>however I want to be able to create a custom <code>UINavigationController</code> (programatically) that already sets my custom navigation bar as its navigation bar class. I have seen how to do it at this link but it seems a bit dated (2012) and 'hacky AF' - <a href="https://stackoverflow.com/a/9610801/2654425">https://stackoverflow.com/a/9610801/2654425</a>. I know how to do it in 'Storyboard' by setting the navigation bar class of the <code>UINavigationController</code> but I would like this to be done programmatically in my Custom UINavigation Controller.</p>
  
  <p>Here is a basic <code>UINavigationBar</code> and <code>UINavigationController</code> Subclass:</p>
  
  <pre><code>class CustomNavigationBar: UINavigationBar {
  
      override init(frame: CGRect) {
          super.init(frame: frame)
  
      }
      required init(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)!
  
  
      }
  
      override func draw(_ rect: CGRect) {
          self.backgroundColor = UIColor.red
      }
  
  
  }
  
  class CustomNavigationController: UINavigationController {
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
  }
  </code></pre>
  
  <p>Im not sure where to set the custom navigation bar. Any help is greatly appreciated. :)</p>