0

Is is possible to use two UICollectionViewLayout in a UICollectionView and use the desired UICollectionViewLayout and load them based on the indexpath.item?

m177312
  • 1,199
  • 2
  • 14
  • 22

1 Answers1

0

No. You can't. Till iOS 7 you either use the flow layout they provide by default or subclass UICollectionViewLayout and create your own custom layout.

Actually the beauty of UICollectionViewLayout lies in UICollectionViewLayoutAttributes that contains all info like frame, size etc. in order to make your UICollectionViewCell look fancy.

During subclassing of UICollectionLayout you'll be overriding the below mentioned method in order to return UICollectionViewLayoutAttribute on basis of your cell's index path.

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath{
    return [self.layoutInfo objectAtIndex:indexPath.item];
}

Here are two great tutorials on creating your custom UICollectionViewLayout : Apple and Skeuo.

Hope this helps.

Aditya Sinha
  • 103
  • 6