title: Transparent UINavigationBar in Swift
body: <p>I am trying to make my <code>UINavigationBar</code> in <code>UINavigationController</code> transparent. I created a subclass of <code>UINavigationController</code> and liked it to a scene in my storyboard file. Here's a piece of my subclass:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      // Do any additional setup after loading the view.
      let size = self.navigationBar.frame.size
      self.navigationBar.setBackgroundImage(imageWithColor(UIColor.blackColor(), size: size, alpha: 0.2), forBarMetrics: UIBarMetrics.Default)
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  func imageWithColor(color: UIColor, size: CGSize, alpha: CGFloat) -&gt; UIImage {
      UIGraphicsBeginImageContext(size)
      let currentContext = UIGraphicsGetCurrentContext()
      let fillRect = CGRectMake(0, 0, size.width, size.height)
      CGContextSetFillColorWithColor(currentContext, color.CGColor)
      CGContextSetAlpha(currentContext, alpha)
      CGContextFillRect(currentContext, fillRect)
      let retval: UIImage = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
      return retval
  }
  </code></pre>
  
  <p>When I run my application a have a navigation bar transparent, but status bar is just black.</p>
  
  <p>For example if I do such thing on <code>UITabBar</code> - it works.</p>