How to scroll to a particluar index in collection view in swift
<p>We have a collection view. I have made a calendar which shows dates horizontally &amp; I scroll dates horizontally. Now on screen I see only 3-4 dates. Now I want to auto scroll to a particular selected date when calendar screen I shown.So the date I want to scroll to is not visible yet.</p>

<p>For that I got the indexpath for particular cell. Now I am trying to scroll it to particular indexpath.</p>

<pre><code>  func scrollCollectionView(indexpath:IndexPath)
  {
   // collectionView.scrollToItem(at: indexpath, at: .left, animated: true)
    //collectionView.selectItem(at: indexpath, animated: true, scrollPosition: .left)
    collectionView.scrollToItem(at: indexpath, at: .centeredHorizontally, animated: true)
    _ = collectionView.dequeueReusableCell(withReuseIdentifier: "DayCell", for: indexpath) as? DayCell

  }
</code></pre>

<p>Please tell how can I implement it?</p>