简体   繁体   中英

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM