JamieNewman
JamieNewman

Reputation: 917

Stop UICollectionView hiding cells out of view bounds

I have a horizontal-scrolling UICollectionView which is nested in a UIView that is centred and occupies 80% of the screen width.

I want the UICollectionView to be visible screen edge-to-edge rather than constrained to the super UIView bounds.

I have set the following which shows the UICollectionView across the screen width:

collectionView.clipToBounds = NO

...but when dragging the collectionView, it hides cells when they are completely outside of the super UIView bounds even though they are partially visible on the screen, which leads to a weird flickering of blank space/cell.

Ideally, I'd like a way to prevent the hiding of the cells completely out of bounds. Is there a way to do this?

The UICollectionView has a maximum size of 3 cells, so I'm not particularly worried about any performance implications of having all cells visible all the time.

Upvotes: 6

Views: 1970

Answers (1)

SoftDesigner
SoftDesigner

Reputation: 5854

The only way I found is to enlarge the frame of the collection view (and its superview in your case) and add contentInset's to it. You might also want to update scrollIndicatorInsets.

Upvotes: 1

Related Questions