title: How to make a sticky header on top UICollectionView
body: <p>Currently I have a header cell in my UICollectionView. When I try to scroll UICollectionView, header cell will scroll together with UICollectionView list.
  May I know how to set the header cell stick on top? Please help. Thank you.</p>
  
  <p>My current result:-
  <a href="https://i.stack.imgur.com/hrL8H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hrL8H.png" alt="enter image description here"></a></p>
  
  <p>My expected result:-
  <a href="https://i.stack.imgur.com/doHFM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/doHFM.png" alt="enter image description here"></a></p>
  
  <p>Here is my sample code for header cell in my ViewController:-</p>
  
  <pre><code>- (UICollectionView *)collectionView
  {
      if (!_collectionView) {
          DCHoverFlowLayout *layout = [DCHoverFlowLayout new];
          _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
          _collectionView.frame = CGRectMake(0, DCTopNavH, ScreenW, ScreenH - DCTopNavH);
  
          _collectionView.showsVerticalScrollIndicator = NO;
          _collectionView.delegate = self;
          _collectionView.dataSource = self;
  
          [_collectionView registerClass:[Product_HeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:Product_HeadViewID];
  
      }
      return _collectionView;
  }
  
  
  
  - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  
      UICollectionReusableView *reusableview = nil;
      if (kind == UICollectionElementKindSectionHeader){
  
          Product_HeadView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:Product_HeadViewID forIndexPath:indexPath];
          WEAKSELF
  
    };
          reusableview = headerView;
          return cell;
      }
  
  -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
  
      _lastContentOffset = scrollView.contentOffset.y;
  
  }
  -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
  {
  
      if(scrollView.contentOffset.y &gt; _lastContentOffset){
          [self.navigationController setNavigationBarHidden:YES animated:YES];
          self.collectionView.frame = CGRectMake(0, 20, ScreenW, ScreenH - 20);
  
          self.view.backgroundColor = [UIColor whiteColor];
      }else{
          [self.navigationController setNavigationBarHidden:NO animated:YES];
          self.collectionView.frame = CGRectMake(0, DCTopNavH, ScreenW, ScreenH - DCTopNavH);
  
          self.view.backgroundColor = ThemeBackgroundColor;
      }
  }
  
  #pragma mark - &lt;UIScrollViewDelegate&gt;
  - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  {
      //Detect Button Visible
      _backTopButton.hidden = (scrollView.contentOffset.y &gt; ScreenH) ? NO : YES;
  
  
      WEAKSELF
      [UIView animateWithDuration:0.25 animations:^{
          __strong typeof(weakSelf)strongSelf = weakSelf;
          strongSelf.footprintButton.dc_y = (strongSelf.backTopButton.hidden == YES) ? ScreenH - 60 : ScreenH - 110;
      }];
  
  }
  </code></pre>
  
  <p><strong>UPDATED:-</strong></p>
  
  <p>After applied Ted's code, here is the result and apps will crash.
  <a href="https://i.stack.imgur.com/mjep7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mjep7.png" alt="enter image description here"></a></p>