I have subclassed the UICollectionViewLayoutAttributes class and added a few custom properties.

In my custom UICollectionViewLayout class, I am overriding the static + (Class)layoutAttributesClass and I return my new attributes class.

In my UICollectionViewLayout class I override the -(NSArray*)layoutAttributesForElementsInRect:(CGRect)rect and I set the values to the custom properties.

I can inspect the attributes class right there and see that the custom properties are set properly.

So, lastly I need to retrieve these properties in the UICollectionViewCell, so I override the -(void) applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes to fetch the values in the custom UICollectionViewLayoutAttributes class, YET they are nil. As if I never set them.

All the rest of the attributes are working perfectly, including transforms and such. So clearly, Im doing something wrong. Please advise.

Included is the HeaderFile of my custom class

@interface UICollectionViewLayoutAttributesWithColor : UICollectionViewLayoutAttributes

@property (strong,nonatomic) UIColor *color;

@end

and here is the implementation. As you can see, nothing special

@implementation UICollectionViewLayoutAttributesWithColor

@synthesize color=_color;

@end
Edit
Report