Jeff
Jeff

Reputation: 1403

UICollectionView clipsToBounds is not working properly with paging

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

Upvotes: 2

Views: 6315

Answers (2)

Cheng-Yu Hsu
Cheng-Yu Hsu

Reputation: 1049

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.

Upvotes: 6

Gürhan KODALAK
Gürhan KODALAK

Reputation: 580

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.

Upvotes: -3

Related Questions