title: UICollectionViewCell doesn't fill the screen
body: <p>I have a <code>UIViewController</code> containing a <code>UICollectionView</code> for vertical paging. The <code>UICollectionView</code> (blue area in the picture) is pinned to the top of the superview, but <code>UICollectionViewCell</code> (yellow) is not. I tried to explicitly pin the top constraint of the <code>UICollectionViewCell</code> to the top of <code>UICollectionView</code> but the program crashes.</p>
  <p><a href="https://i.stack.imgur.com/8Ub4y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Ub4y.png" alt="Collection view (blue area) is filling the screen but the view cell (yellow) is misplaced" /></a></p>
  <pre><code>class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout {
  
    override func viewDidLoad() {
      super.viewDidLoad()
      
      let collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: UICollectionViewFlowLayout())
      collectionView.register(FeedCell.self, forCellWithReuseIdentifier: reuseIdentifier)
      collectionView.backgroundColor = .blue
      collectionView.showsVerticalScrollIndicator = false
      collectionView.isPagingEnabled = true
      
      view.addSubview(collectionView)
      
      collectionView.translatesAutoresizingMaskIntoConstraints = false
      NSLayoutConstraint.activate([
        collectionView.topAnchor.constraint(equalTo: view.topAnchor),
        collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
        view.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor),
        view.trailingAnchor.constraint(equalTo: collectionView.trailingAnchor)
      ])
      
      collectionView.dataSource = self
      collectionView.delegate = self
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
      .lightContent
    }
    
    // MARK: UICollectionViewDelegateFlowLayout
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: view.frame.width, height: collectionView.bounds.height)
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0
    }
  }
  
  extension HomeViewController: UICollectionViewDataSource {
    func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
      1
    }
  
  
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      4
    }
  
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
      cell.backgroundColor = indexPath.item % 2 == 0 ? .yellow : .orange
      
      return cell
    }
    
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -&gt; UIEdgeInsets {
      return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    }
  }
  </code></pre>