title: iOS UITableView HeaderView Stick to UINavigationBar on Pulldown
body: <p>I am attempting to get the header view of my <code>uitableview</code> to stick to the bottom of the navigation bar when pulled down, and hide behind it when scrolling up.</p>
  
  <p>Here is what I have for making it hide on scroll up.</p>
  
  <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
      CGFloat sectionHeaderHeight = 40;
      if (scrollView.contentOffset.y &lt;= sectionHeaderHeight &amp;&amp; scrollView.contentOffset.y &gt;= 0) {
          scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
          NSLog(@"contentOffset: %f contentinset: %f", scrollView.contentOffset.y, scrollView.contentInset.top);
      } else if (scrollView.contentOffset.y &gt;= sectionHeaderHeight) {
          NSLog(@"1ST contentOffset: %f contentinset: %f", scrollView.contentOffset.y, scrollView.contentInset.top);
          scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
      }
  }
  </code></pre>
  
  <p>I have been messing with insets and offset to try to get it to stick to to the navigation bar when pulling down. The image below demonstrates the behavior that is happening, and when the <code>scrollview</code> is pulled down, I do not want the red section to come down with it.</p>
  
  <p>I've been thinking of other ways of doing this, and adding a subview that changes it's position and height during <code>scrollViewDidScroll</code> may be an option, but I am not sure how to assign it to the <code>uinavigationbar</code> instead of the <code>scrollview</code>. And I am not sure how to dynamically change it's height during that. </p>
  
  <p>I have also found this: <a href="https://github.com/telly/TLYShyNavBar" rel="nofollow noreferrer">https://github.com/telly/TLYShyNavBar</a>
  Which does exactly what I want it to do if I disable the <code>uinavigationbar</code> hiding, but it has issues working with the <code>uitableviewcontroller</code> and opaque navigation bars. </p>
  
  <p>Can anyone point me in the right direction of what I could possibly do, or if there is an existing solution that I am not aware of?</p>
  
  <p><img src="https://i.stack.imgur.com/5yLMt.gif" alt="enter image description here"></p>