title: Swift iOS -CollectionView how to scroll cells off of screen
body: <p>I have a collectionView with 4 cells. Since there are only 4 cell inside the collection view it won't scroll any further. </p>
  
  <p>When scrolling up I want to scroll the 4 cells off of the screen (collectionView will appear empty). Once the cells are off screen I want the scrolling to stop, I don't want to scroll forever. When scrolling back down I want to scroll the 4 cells back onto the scene.</p>
  
  <p>I tried changing the <code>collectionView.bounds.origin</code> and the <code>collectionView.contentSize.height</code> but neither worked, I still couldn't scroll the 4 cells off of the screen.</p>
  
  <p>I can always add clear cells but that seems like a hack.</p>
  
  <p><strong>What is the appropriate way to accomplish this?</strong></p>
  
  <pre><code>override func viewDidLoad() {
         super.viewDidLoad()
  
         let layout = UICollectionViewFlowLayout()
         layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0)
         layout.scrollDirection = .vertical
  
         collectionView = UICollectionView(frame: view.frame, collectionViewLayout: layout)
         collectionView.delegate = self
         collectionView.dataSource = self
         collectionView.alwaysBounceVertical = true
         collectionView.backgroundColor = .white
         collectionView.register(MyCell.self, forCellWithReuseIdentifier: myCell)
         view.addSubview(collectionView)
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
         return 4
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: myCell, for: indexPath) as! MyCell
         cell.textLabel.text = "Hello"
         return cell
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
         return CGSize(width: view.frame.width, height: 44)
  }
  </code></pre>