locked
Adjust item position in UICollectionView RRS feed

  • Question

  • User38482 posted

    I'm using a UICollectionView to create a Pinterest-style layout. I'm using self-sizing cells to adjust to different photo heights (I've set the contentView background color to green to demonstrate), but the y position of the items in a row is being set by the largest cell in the row. What would be the best way of getting the individual items to adjust as shown by the arrows?

    Do I have to subclass UICollectionViewLayout to get this level of control?

    Tuesday, August 14, 2018 2:43 PM

Answers

  • User369979 posted

    @PhilipJohn Yes, you need to customize your own UICollectionViewLayout to get this effect. Fortunately, the official documentation has offered us the water falling layout here. Also you can refer to this sample for the detail codes.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, August 15, 2018 9:28 AM