UICollectionView clipsToBounds在分页中无法正常工作 [英] UICollectionView clipsToBounds is not working properly with paging
问题描述
我正在使用启用了水平分页的UICollectionView.
我的collectionView框架小于屏幕尺寸.
I am using UICollectionView with horizontal paging enabled.
My collectionView frame is less than the screen size.
我使用了以下代码:
myCollectionView.clipsToBounds=FALSE;
仍然无法在我的collectionView范围之外看到视图.
我正在使用自定义UICollectionViewLayout
Still I am not able to see the views outside the bounds of my collectionView.
I am using custom UICollectionViewLayout
推荐答案
如果每个页面的大小大于或等于collectionView
的框架大小,则即使在框架外部,您也将无法看到内容clipToBounds
被禁用.
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.
为了节省内存,collectionView
中的单元格是可重复使用的,如果它们不在框架内(即,仅显示 visible 单元格),则会将其删除.
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).
要重现类似于在App Store上看到的效果:
To recreate the effects like the one seen on the App Store:
尝试将collectionView
的框架设置为与collectionView
的superView
一样大,并为UICollectionViewFlowLayout
指定正确的minimumLineSpacing
.
Try to set the frame of the collectionView
as large as your collectionView
's superView
, and specify proper minimumLineSpacing
for your UICollectionViewFlowLayout
.
您可能想看一下有关 targetContentOffsetForProposedContentOffset:withScrollingVelocity
的帖子,该控件使您可以决定
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.
这篇关于UICollectionView clipsToBounds在分页中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!