title: UICollectionViewCell has left offset
body: <p>In my Today Widget I use a <code>UICollectionView</code> with some different size cells in it. </p>
  
  <pre><code>let layout = UICollectionViewFlowLayout.init()
  layout.scrollDirection = UICollectionViewScrollDirection.vertical;
  collectionView = UICollectionView.init(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height), collectionViewLayout: layout)
  collectionView.delegate = self
  collectionView.dataSource = self
  collectionView.backgroundColor = UIColor.green
  collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
  
  self.view.addSubview(collectionView)
  </code></pre>
  
  <p>I then create those cells with some placeholder colors for now:</p>
  
  <pre><code>func numberOfSections(in collectionView: UICollectionView) -&gt; Int {
      return 1
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -&gt; CGSize {
      return CGSize.zero
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0.0
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -&gt; CGFloat {
      return 0.0
  }
  
  func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
      if (pokemon.count == 0) {
          if (indexPath.row == 1) {
              return CGSize.init(width: self.view.frame.size.width, height: 220)
          } else {
              return CGSize.init(width: self.view.frame.size.width, height: 110)
          }
      } else {
          if (indexPath.row == 0) {
              return CGSize.init(width: self.view.frame.size.width, height: 110)
          } else {
              return CGSize.init(width: self.view.frame.size.width, height: 56)
          }
      }
  }
  
  func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
      if (pokemon.count == 0) {
          return 2
      } else {
          return pokemon.count+1
      }
  }
  
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath)
  
      if (indexPath.row == 0) {
          cell.backgroundColor = UIColor.yellow
      } else if (indexPath.row == 1) {
          cell.backgroundColor = UIColor.red
      } else if (indexPath.row == 2) {
          cell.backgroundColor = UIColor.purple
      }
  
      return cell
  }
  </code></pre>
  
  <p>Now, what happens is that my cells have a left offset and I can't figure out why that is. I attached a screenshot of the behaviour. I tried setting the layout with the minimum distances included directly, but that didn't have any effect. Any ideas?</p>
  
  <p><a href="https://i.stack.imgur.com/JzZeQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JzZeQ.png" alt="a screenshot"></a></p>