collection view swift with different sizes and different datas

hello everybody!

I searched a lot online but found no information about it!

If there is a guide or post that has already been written, I would be happy to share with me.



My question is how do I do the next thing?

Can anyone please explain to me ...

I want to show the first line of information a and a size 20 that scrolls to the left and right.

Second-row information b and size 10 scrolled to the left and right side

Third-row information c and size 5 scrolled to the left and right side



And that it repeats itself but each time with other information to cause the state of infinite scrolling in the vertical state.



The information I take from the JSON file!

I would be happy if someone could explain the important steps to achieve this outcome!

Sorry for my English!


I have attached a photo.


https://ibb.co/gxyp3J



Waiting impatiently for help!



Thanks!

Replies

You should use :


optional func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize


Do you have different sections for each group of 3 rows ?

if yes:

for row == 0, give a size, for row == 1 another, for row == 2 yet a new one.

if no

for row % 3 == 0, give a size, for row % 3 == 1 another, for row % 3 == 2 yet a new one.