title: UICollectionView hide/prevent cell scrolling behind Sticky Header
body: <p>I have a collection view with sticky headers </p>
  
  <pre><code> flowLayout.sectionHeadersPinToVisibleBounds = true
  </code></pre>
  
  <p>My issue is that the top half of my header is translucent and when I scroll my cell up I can see the cell scrolling behind the header.</p>
  
  <p>I would like to hide the part of the cell view behind the header. In my image attached I do not want to see the green when it is behind the red. The rest of the behavior I want to keep as is.</p>
  
  <p>The reason I need this is I have a wallpaper image at the very back which I need to be shown</p>
  
  <p><a href="https://i.stack.imgur.com/Trnlk.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Trnlk.gif" alt="Sticky CollectionViewHeaders "></a> </p>
  
  <pre><code>@IBOutlet weak var collectionView: UICollectionView!
  override func viewDidLoad() {
      super.viewDidLoad()
      self.collectionView.alwaysBounceVertical = true
      collectionView.register(UINib.init(nibName: EXAMPLE_CELL_REUSE_ID, bundle: nil), forCellWithReuseIdentifier: EXAMPLE_CELL_REUSE_ID)
      collectionView.register(UINib.init(nibName: EXAMPLE_HEADER_REUSE_ID, bundle: nil), forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: EXAMPLE_HEADER_REUSE_ID)
  
      if let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
        flowLayout.headerReferenceSize = CGSize(width: 400, height: 100)
        flowLayout.sectionHeadersPinToVisibleBounds = true
    }
  }
  
  
  
  
  func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
      return sections.count;
   }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 1 //self.sections[section].1;
  }
  
  
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let exampleCell = collectionView.dequeueReusableCell(withReuseIdentifier: EXAMPLE_CELL_REUSE_ID, for: indexPath) as! MyCellCollectionViewCell;
  
      exampleCell.headerLabel.text = "Cell"
      exampleCell.backgroundColor = UIColor.green
  
      return exampleCell;
  }
  
  
  func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -&gt; UICollectionReusableView {
      if kind == UICollectionElementKindSectionHeader {
        if let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: EXAMPLE_HEADER_REUSE_ID, for: indexPath) as? ExampleHeader {
         //  header.backgroundColor = UIColor(red: 1.0, green: 0, blue: 0, alpha: 0.5)
          return header
        } else {
          return UICollectionReusableView()
  
        }
      }
      return UICollectionReusableView()
  }
  </code></pre>
  
  <p>I think the question here may be similar but there are no responses and it is not quite clear if it is the same issue.
  <a href="https://stackoverflow.com/q/44739618/1463518">Transparent sticky header ui collectionview don&#39;t show cells underneath</a></p>