I want to make paging/scrolling in UIScrollView to be faster, so when the user lefts his finger the next page will come faster than normal regardless the speed of the acceleration.
Tweak the decelerationRate
of your UIScrollView.
More reading: UIScrollView Class Reference
If I understand your question correctly, you've setup the ScrollView to snap to pages (pagingEnabled = YES). When the the user lifts their finger you want it to snap to the closest page quicker than what it currently does?
If that's what you're trying to accomplish, this is what I recommend:
scrollViewDidEndDragging:willDecelerate:
. You will also want to override the method scrollViewWillEndDragging:withVelocity:targetContentOffset:
so that you can get the velocity of the drag.scrollViewDidEndDragging:willDecelerate:
, you can calculate the direction of the drag (using the velocity you got from the other method) and the offset to the nearest page. From there, it's as simple as setting the contentOffset of the scrollview using a UIView
animation block with the desired duration. For example:[UIView animateWithDuration:.25f animations:^{
scrollview.contentOffset = calculatedCGPoint;
}];
That should give you the desired effect.
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