title: How to use collectionview flow layout to get correct view?
body: <p>I am using this code to get correct type but not getting the view what i want can any one tell me where am i wrong</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
      screenSize = UIScreen.main.bounds
      screenWidth = screenSize.width
      screenHeight = screenSize.height
      videosCollectionView.delegate = self
      videosCollectionView.dataSource = self
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      return 4
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = videosCollectionView.dequeueReusableCell(withReuseIdentifier: "Videos", for: indexPath as IndexPath) as! VideosCollectionViewCell
      cell.mainImgVw.image = logoImage[indexPath.row]
      cell.durationLabel.text = "duration"
      cell.nameLabel.text = "Test Video"
      return cell
  
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      let xPadding = 10
      let spacing = 10
      let rightPadding = 10
      let width = (CGFloat(UIScreen.main.bounds.size.width) - CGFloat(xPadding + spacing + rightPadding))/2
      let height = CGFloat(215)
  
      return CGSize(width: width, height: height)
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -&gt; UIEdgeInsets {
      return UIEdgeInsetsMake(10, 10, 10, 10)
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IrFBG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IrFBG.png" alt="what i want"></a></p>
  
  <p>and what i am getting 
  <a href="https://i.stack.imgur.com/cfwbU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cfwbU.png" alt="this i am getting"></a></p>
  
  <p>Please tell me where i am wrong. Please help me.</p>
  
  <p>My storyboard is like this <a href="https://i.stack.imgur.com/4Fyj8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Fyj8.png" alt="enter image description here"></a></p>