I'm trying to slow down the scroll in a UICollectionView. Everything works great and the distance between the cells is fine, but it just moves too fast.
How can I adjust the sensitivity or speed of the scroll?
[Edit] I forgot to mentioned that I already tried:
self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast;
and
self.collectionView.decelerationRate = UIScrollViewDecelerationRateNormal;
With no significant change in speed...
UICollectionView
is a subclass of UIScrollView
, so you can adjust the decelerationRate
in your collection view controller's viewDidLoad
, like so:
Objective-C:
- (void)viewDidLoad
{
[super viewDidLoad];
self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast;
};
Swift:
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast
}
For anyone looking how to do it in Swift
self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast
Swift 5:
self.collectionView.decelerationRate = UIScrollView.DecelerationRate.fast
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