Search code examples
iosswiftuicollectionviewuikit

UICollectionView.scrollToItem set animation speed


When using collectionView.scrollToItem with IndexPath. is it possible to set custom scroll speed?


Solution

  • Yes, it is possible. Try this:

    UIView.animate(withDuration: 5, animations: { [weak self] in
        self?.collectionView.scrollToItem(at: IndexPath(item: 10, section: 10), at: .middle, animated: false)
    })