Skip to content

Instantly share code, notes, and snippets.

@alltom
Created March 22, 2014 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alltom/9712991 to your computer and use it in GitHub Desktop.
Save alltom/9712991 to your computer and use it in GitHub Desktop.
@implementation VP2CollectionViewLayout
#pragma mark - Called during the layout process
// step 1
- (void)prepareLayout
{
// if it's not too much data, create all element attributes here
}
// step 2
- (CGSize)collectionViewContentSize
{
return CGSizeZero;
}
// step 3
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
// at a minimum, each attribute should have size and position
// set zIndex if they overlap
// you can subclass UICollectionViewLayoutAttributes if you need to
return @[];
}
#pragma mark - Other
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
// cannot modify attributes here
return nil;
}
// use for headers and footers
// the elements come from the data source
- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
#pragma mark - For insertion/deletion animation
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath *)itemIndexPath
{
return nil;
}
- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:(NSIndexPath *)itemIndexPath
{
return nil;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment