0

I am designing an app that has the following layout. I was thinking of having the view as a collectionview.

A and B are a custom collection cells. How would I design the app so that the second and third rows have 2 and 3 cells as shown in the image?

enter image description here

I tried over-riding the sizeForItemAt indexPath method and then calculating the size of each cell based on the row it is in. Not only it seems a little odd and but the cells don't align properly either.

I tried setting the estimatedItemSize property as well as over-riding preferredLayoutAttributesFitting by following this link.

Is there an easier way to do this UI ? Should I remove colleciton view and go with plain ol tableviews ? Any help would be much appreciated.

dev
  • 1,166
  • 11
  • 23
  • You need to implement a `UICollectionViewDelegateFlowLayout` and return an appropriate size from the `sizeForItemAt` function – Paulw11 Oct 22 '17 at 08:46
  • 1
    Sonu, you say "I tried over-riding the `sizeForItemAt`" ... Yeah, that seems like the most logical approach. You go on to say "but the cells don't align properly either" ... I'd suggest you show us snippets of the relevant code and a screen snapshot of what it ended up looking like. When you set the size, just make sure you account for whatever spacing you have... – Rob Oct 22 '17 at 12:21
  • Thanks for the comment Rob. "but the cells don't align properly either" - this was due to the fact that collectionview had min spacing values present in storyboard. The issue has been resolved and the cells allign perfectly now. – dev Oct 23 '17 at 21:30

0 Answers0