I want to create a custom UICollectionViewFlowLayout
to change the way the headers and cells are displayed on the collection view.
I subclassed UICollectionViewFlowLayout
and overridden the layoutAttributesForElementsInRect
method where I create my custom positioned UICollectionViewLayoutAttributes
objects.
The thing is that I am not using [super layoutAttributesForElementsInRect:(CGRect)rect]
to generate the UICollectionViewLayoutAttributes
and because of that my screen is blank.
If I use the [super layoutAttributesForElementsInRect:(CGRect)rect]
method to get the UICollectionViewLayoutAttributes
, the collection view is displayed but in the default way.
I am creating my UICollectionViewLayoutAttributes
using this code:
UICollectionViewLayoutAttributes *cell = [UICollectionViewLayoutAttributes
layoutAttributesForCellWithIndexPath:[NSIndexPath indexPathForRow:item inSection:section]];
[cell setAlpha:self.cellOpacity];
[cell setHidden:NO];
[cell setSize:self.itemSize];
[cell setZIndex:self.cellZIndex];
[cell setFrame:CGRectMake ((self.itemSize.width * item) + self.cellPadding,
(section * self.itemSize.height) + self.cellPadding,
self.itemSize.width,
self.itemSize.height)];
[itemsLayoutAttributes addObject:cell];
Is something wrong with the fact that I am creating the UICollectionViewLayoutAttributes
manually and not using the ones created by the super method?
What do you think I am doing wrong?
Thank you in advance!