title: iOS: Stretching / Resizing UITableView Header As The User Drags Down?
body: <p>Using storyboard, I have placed an <code>imageView</code> as my <code>tableView's</code> <code>headerView</code> inside a <code>ViewController</code>.</p>
  
  <p>This is how my storyboard is set up:</p>
  
  <p><img src="https://i.stack.imgur.com/dUa0d.png" alt="enter image description here"></p>
  
  <p>Depending on what data the user is viewing, the <code>viewController</code> will either show or hide the <code>headerView</code>. My question is, that when the <code>headerView</code> is visible and the user drags down on the <code>tableView</code>, <strong>how can I have the <code>imageView</code> stick to both the <code>navigationBar</code> and the <code>tableView</code> as it resizes to cover the space in between?</strong></p>
  
  <p>This is what it currently does:</p>
  
  <p><img src="https://i.stack.imgur.com/69VCh.jpg" alt="enter image description here"></p>
  
  <p>But this is what I'm going for:</p>
  
  <p><img src="https://i.stack.imgur.com/TRIC8.jpg" alt="enter image description here"></p>
  
  <p>Any help would be greatly appreciated. I've looked at parallax libraries, but none support sectionTitles, and I'm not necessarily going for the parallax effect either. When the user scrolls up, I want it to bounce back to the regularView and not hide the headerView. Thanks!</p>
  
  <blockquote>
    <h2>UPDATE:</h2>
    
    <p>I have followed the advice posted by Dany below and have done the
    following:</p>
  
  <pre><code>-(void)scrollViewDidScroll:(UIScrollView*)scrollView {
  
  CGRect initialFrame = CGRectMake(0, 0, 320, 160);
  
  if (scrollView.contentOffset.y &lt; 0) {
  
      initialFrame.size.height =! scrollView.contentOffset.y;
      childHeaderView.frame = initialFrame;
  } }
  </code></pre>
    
    <p>childHeaderView is an imageView and for some reason when I drag down,
    the image moves up (like half of it behind the navBar) and doesn't return. Any advice would be
    greatly appreciated!! Thanks!</p>
  </blockquote>