Monday 13 January 2020

How to change UIScrollView with isPagingEnabled autoscroll drag trashhold

I have horizontal UIScrollView with isPagingEnabled = true containing few pages. If I drag scrollview content and release finger it scrolls to next page only if I dragged at least 50% of scrollview width. I want to auto scroll to next/previous page if drag distance is more than 25%.

I was able to achieve it by overriding scrollViewDidEndDragging in UIScrollViewDelegate, calculating drag distance and calling scrollView.setContentOffset. But issue is that if distance > 25 and < 50 then it scrolls back automatically probably because scrollview calls it's default implementation.

Any idea how can I achieve this? Thanks



from How to change UIScrollView with isPagingEnabled autoscroll drag trashhold

No comments:

Post a Comment