1

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!

enter image description here

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. I have managed to create my own custom layout which meet my scenario perfectly.
In my case, I can't use waterfall style since the width is not fixed. Actually, custom layout is easier that what I thought initially.
1

You can create your custom UICollectionViewLayout, I have found this tutorial very useful: custom layout

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.