Custom layout for different cell sizes in UICollec

2019-01-31 01:37发布

问题:

I would like to use the new UICollectionView, but I'm not sure if it is possible to build the following:

As you can see, there are two different cell types. One is portrait, one is landscape. When I use the flow layout, it always creates rows of cells which are as high as the tallest cell. Not this kind of "fluid" layout I need.

Is it possible at all to achieve this kind of layout with a UICollectionView?

Has anyone done something like this before? Are there any samples? I already checked out many tutorials and the Class References ...

Thanks!

回答1:

You can check out https://github.com/bryceredd/RFQuiltLayout . Looks like something you can use for this



回答2:

It is possible with the FlowLayout, but you have to customize the FlowLayout Attributes.

Apple gives a good explanation, see Collection View Programming Guide for iOS scroll down to Specifying the Size of Items in the Flow Layout



回答3:

This might be possible using UICollectionViewFlowLayout