Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 966
JamieNewman Avatar asked Nov 09 '22 01:11

JamieNewman


1 Answers

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.

like image 107
SoftDesigner Avatar answered Nov 14 '22 22:11

SoftDesigner