Custom paging size in page scroll view

Originator:douglashill
Number:rdar://36248271 Date Originated:01-Jan-2018 06:45 pm
Status:Open Resolved:
Product:iOS + SDK Product Version:11.2
Classification:Enhancement Reproducible:Always
 
Summary:
My app shows a collection view where the user scrolls in discrete pages. At any time you can see a bit of the pages to the left and right on the sides. In other words, the paging distance is slightly less than the width of the collection view.

In a scroll view that isn’t a collection view, you can achieve this effect by disabling clipsToBounds and making the scroll view the width of a page but leaving space clear on each size. This does not work for a collection view because UICollectionView uses its bounds to determine which cells to display and when they can be removed and reused.

My solution is to disable scrolling in the collection view and add a hidden paging scroll view with the width of a page, then move the hidden view’s pan gesture recogniser to the collection view. Then whenever the hidden view scrolls set the content offset of the collection view. This works very well but does make my code a bit more complex.

One way UIKit could make this simpler is if UIScrollView provided API to set the paging width independently of its bounds’ width.

Steps to Reproduce:
Try to make an app with a paging scroll view where you can see the edges of the pages on each side.

Expected Results:
Should be easy, such as a property on the scroll view that I can set as part of my layout process.

Actual Results:
Have to use workarounds like not clipping to bounds, or creating a hidden scroll view of the desired paging width.

Version:
11.2

Notes:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!