title: Subclassing UINavigationBar in Swift
body: <p>I'm trying to create a custom <code>UINavigationBar</code> class and then use the <code>Storyboard</code> to set it as the class of my <code>UINavigationController</code>'s NavigationBar.<br/></p>
  
  <p>Here's the code of my <code>UINavigationBar</code> class:</p>
  
  <pre><code>class CustomNavBar: UINavigationBar {
  
      override func drawRect(rect: CGRect) {
          super.drawRect(rect)
          // Drawing code
          self.backgroundColor = UIColor.orangeColor()
  
          let myLabel = UILabel(frame: CGRect(x: 0, y: 4, width: 600, height: 36))
          myLabel.backgroundColor = UIColor.purpleColor()
          myLabel.textColor = UIColor.yellowColor()
          myLabel.text = "Custom NavBar!"
  
          self.addSubview(myLabel)
      }
  
  }
  </code></pre>
  
  <p>Then, in Interface Builder, I use the <code>Identity Inspector</code> to set this as the class of the <code>NavigationBar</code> of my <code>UINavigationController</code>.<br/></p>
  
  <p>When I run the App - it freezes. It hangs up on the <code>LaunchScreen.xib</code> and doesn't do anything.<br/></p>
  
  <p>Why is doing that? What's the right way to go about doing this?</p>