IGListKit icon indicating copy to clipboard operation
IGListKit copied to clipboard

Getting item size in custom layout

Open Recouse opened this issue 6 years ago • 3 comments
trafficstars

New issue checklist

How can I get value of - (CGSize)sizeForItemAtIndex:(NSInteger)index; method in my custom UICollectionViewLayout?

Recouse avatar Feb 06 '19 09:02 Recouse

I have a similar issue where my custom UICollectionViewLayout does the size calculation to adapt to the screen (list vs grid), something I'm not sure I want to leave to the ListSectionController and where collectionContext doesn't have enough info anyway.

popei69 avatar Mar 06 '19 07:03 popei69

I am trying to do Pinterest layout Any Ideas are welcome

jassimkm avatar Aug 09 '19 10:08 jassimkm

@jassimkm You can get item size from the adapter with layout delegate. Like this:

extension ViewController: CustomCollectionViewLayoutDelegate {
    func sizeForItem(at indexPath: IndexPath) -> CGSize {
        return adapter.sizeForItem(at: indexPath)
    }
}

Recouse avatar Aug 19 '19 17:08 Recouse