2

I am using UICollectionView with horizontal paging enabled.
My collectionView frame is less than the screen size.

I used the following code :

myCollectionView.clipsToBounds=FALSE;

Still I am not able to see the views outside the bounds of my collectionView. I am using custom UICollectionViewLayout

Jeff
  • 1,405
  • 3
  • 26
  • 46

2 Answers2

6

If the size of each page is greater or equal to your collectionView's frame size, you will not be able to see the content outside the frame even clipToBounds is disabled.

In order to save the memory, the cells in the collectionView are reusable and will be removed if they are out of the frame (i.e. only shows the visible cells).

To recreate the effects like the one seen on the App Store:

Try to set the frame of the collectionView as large as your collectionView's superView, and specify proper minimumLineSpacing for your UICollectionViewFlowLayout.

You may like to take a look at this post about targetContentOffsetForProposedContentOffset:withScrollingVelocity which gives you controls to decide the contentOffset of a given page.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Cheng-Yu Hsu
  • 1,029
  • 7
  • 11
  • Great answer! Keep it up. – Anish Kumar Jan 25 '18 at 22:45
  • For this you should also set `collectionView.contentInset` so that the first and last cells can be centered. I found this answer to be particularly helpful: https://stackoverflow.com/a/38648516/4139760 – blwinters Apr 17 '18 at 21:22
-3

I'm not sure but may be the problem when you init your collectionView it's initializing with the some default settings like clipToBounds. Try this method to layout subviews:

-(void)layoutSubviews{
   [super layoutSubviews];
   myCollectionView.clipsToBounds = FALSE;
}

Hope it works.

Gürhan KODALAK
  • 570
  • 7
  • 20