title: Swift - Shrink Navigation Bar on scroll
body: <p>I'm really stuck here. I would like to shrink the Navigation Bar when I scroll down a UITableView and enlarge it again when scrolling up. I managed to alter the size of the Navigation Bar, but the title image is not shrinking with the Navigation Bar. </p>
  
  <p>I want to do it exactly like Safari, and the problem is that the height of my TitleView is shrinking but the width never changes.</p>
  
  <p>Here's the code I've used to get the height of the scrollbar to change.</p>
  
  <pre><code>func scrollViewDidScroll(scrollView: UIScrollView) {
      var navbar = navigationController?.navigationBar
      var dir:CGPoint = tableview.panGestureRecognizer.translationInView(self.tableview)
      var scrollViewHeight = tableview.frame.size.height
      var scrollContentSizeHeight = tableview.contentSize.height
      var scrollOffset = tableview.contentOffset.y
  
      if (dir.y &gt; 0 &amp;&amp; self.formernavstate == "small") {
          self.formernavstate = "big"
  
          UIView.animateWithDuration(0.5, delay:0.0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -&gt; Void in
  
          println("")
          navbar?.frame.origin.y = 20
          self.navigationItem.titleView?.transform = CGAffineTransformMakeScale(0.52, 0.6)
          }, completion: nil)
      }
  
      if (dir.y &lt; 0 &amp;&amp; self.formernavstate == "big") {
          self.formernavstate = "small"   
          navbar?.frame.origin.y = 0
          navigationItem.titleView?.transform = CGAffineTransformMakeScale(0.0001, 0.2)
      }
  }
  </code></pre>