title: how to use center vertically cells in collection view in paging mode in swift 4?
body: <p>I read 
  <a href="https://stackoverflow.com/questions/33961616/how-to-vertically-center-uicollectionview-content">How to vertically center UICollectionView content</a>
   But when I used the codes here </p>
  
  <pre><code>func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -&gt; UIEdgeInsets {
  
  let navBarHeight       = self.navigationController?.navigationBar.frame.height
  let collectionViewHeight = (self.collectionView?.frame.height)! - navBarHeight!
  let itemsHeight        = self.collectionView?.contentSize.height
  
  let topInset = ( collectionViewHeight - itemsHeight! ) / 4
  
  return UIEdgeInsetsMake(topInset ,0, 0 , 0)
  }
  </code></pre>
  
  <p>But when scrolling collection view this will show incorrect form 
  so here is my codes because my collection view cells are square and equal to screen width </p>
  
  <pre><code>override func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()
  
      showImagesCV.contentInset = UIEdgeInsets(top: spacing, left: spacing, bottom: spacing, right: spacing)
      if let flowLayout = showImagesCV.collectionViewLayout as? UICollectionViewFlowLayout{
          cellWidth = UIScreen.main.bounds.width
          cellHeight = cellWidth //yourCellHeight = cellWidth if u want square cell
          flowLayout.minimumLineSpacing = spacing
          flowLayout.minimumInteritemSpacing = spacing
          UIView.performWithoutAnimation {
          }
      }
    }
  }
  
  extension showImagesViewController : UICollectionViewDelegateFlowLayout {
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      return CGSize(width: cellWidth, height: cellHeight)
    }
  }
  </code></pre>
  
  <p>I want the spacing between cells be 0 and each cell that is showing (current page (because the collection view is in paging mode)) be the center of the screen 
  <a href="https://i.stack.imgur.com/TCyEX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TCyEX.png" alt="here is the problem in the photo"></a></p>