简体   繁体   English

具有自定义布局的UICollectionView布局

[英]UICollectionView layout with custom layout

Is it possible to create a collection view with an item on the left and two items stacked to the right of it? 是否可以创建一个收藏视图,其中一个项目在左侧,两个项目堆叠在右侧?

Whenever I specify the correct sizes to do this in the sizeForItemAtIndexPath delegate I can only get one item on the right side and the other is displayed in the next row underneath. 每当我在sizeForItemAtIndexPath委托中指定正确的大小来执行此操作时,我只能在右侧获得一项,而另一项则显示在下面的下一行中。 I know I can do this with custom cells that contain more than one view (top and bottom) but I would like to know if its possible without that. 我知道我可以使用包含多个视图(顶部和底部)的自定义单元格来做到这一点,但我想知道如果不这样做,是否有可能。 It would be a lot less complex if I could do it without the custom double view cell. 如果我没有自定义的双重视图单元就可以做到,那么它就会简单得多。 Im using a 'flow' layout with 'vertical' scroll direction (as per IB). 我使用“垂直”滚动方向(按照IB)的“流”布局。

First image is what I hope to achieve and the second is what I am able to achieve currently. 第一个图像是我希望实现的目标,第二个图像是我目前能够实现的目标。

我想做的事

发生了什么

您需要为此实现自定义UICollectionViewFlowLayout子类- 创建自定义布局

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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