简体   繁体   中英

UICollectionView flow layout issue

I want to implement a collection view(scroll vertically) layout like the left of the following image. But when I use UICollectionViewFlowLayout, it looks like the right one. So is it possible to achieve this with flow layout, or I need to look into custom layout? Thanks in advance!

在此处输入图片说明

You need a custom layout. The flow layout will arrange items in rows, then break onto the next row when it runs out of width, as you're seeing there.

There are plenty of "waterfall" style layouts available online, such as this one which I've used a couple of times. You need to set a consistent column width and number of columns for these, though - I can't tell from your drawing if that is the case.

您可以创建自定义UICollectionViewLayout ,我发现本教程非常有用: 自定义布局

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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