How to set up a horizontal collection view w paging and a single cell centered on-screen with edges of other cells visible

时间:2016-08-31 18:19:36

标签: ios uicollectionview

I haven't worked with collection views a whole lot.

A client wants a horizontal collection view set up with paging enabled.

They want a single cell centered in the collection view, with the edges of neighboring cells peeking into the view to provide a visual cue that they can swipe to see other cells.

If I set up the collection view using paging and a default flow layout, as I page over each cell ends up shifted to the left a bit more.

I implement the UICollectionViewDelegateFlowLayout protocol's collectionView(_:layout:insetForSectionAtIndex:) method, I can set up section insets such that each cell is kept centered, but when I do that the neighboring cells don't appear, and ONLY the current cell is ever visible until you start scrolling.

I assume I need to do something with a custom flow layout, but I'm not sure what, exactly. Can somebody offer some guidance?

(I'm working in Swift 2.3, although I'm "bilingual", so answers in either Swift or Objective-C are fine.)

0 个答案:

没有答案