I'm a newbie in Swift, please bear with me.
I have created a UICollectionView that scrolls horizontally, my question is: how can you move to the selected icon programmatically?
I have already used didSelectedPath, whats next?
You need to call scrollToItemAtIndexPath function:
Scrolls the collection view contents until the specified item is visible.
func scrollToItemAtIndexPath(_ indexPath: NSIndexPath,
atScrollPosition scrollPosition: UICollectionViewScrollPosition,
animated animated: Bool)
Parameters
indexPath
The index path of the item to scroll into view.
scrollPosition
An option that specifies where the item should be positioned when scrolling finishes. For a list of possible values, see UICollectionViewScrollPosition.
animated
Specify true to animate the scrolling behavior or false to adjust the scroll view’s visible content immediately.
Check UICollectionView class reference with more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With