ZLCollectionViewBackgroundViewLayoutAttributes.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // ZLCollectionViewBackViewLayoutAttributes.m
  3. // ZLCollectionView
  4. //
  5. // Created by zhaoliang chen on 2020/4/17.
  6. // Copyright © 2020 zhaoliang chen. All rights reserved.
  7. //
  8. #import "ZLCollectionViewBackgroundViewLayoutAttributes.h"
  9. @implementation ZLCollectionViewBackgroundViewLayoutAttributes
  10. @synthesize headerFrame = _headerFrame;
  11. @synthesize footerFrame = _footerFrame;
  12. + (instancetype)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind withIndexPath:(NSIndexPath *)indexPath orginalFrmae:(CGRect)orginalFrame{
  13. ZLCollectionViewBackgroundViewLayoutAttributes *layoutAttributes = [super layoutAttributesForDecorationViewOfKind:decorationViewKind withIndexPath:indexPath];
  14. [layoutAttributes setValue:[NSValue valueWithCGRect:orginalFrame] forKey:@"orginalFrame"];
  15. layoutAttributes.frame = orginalFrame;
  16. return layoutAttributes;
  17. }
  18. -(CGRect)orginalFrame {
  19. if ([self.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
  20. return _headerFrame;
  21. } else if ([self.representedElementKind isEqualToString:UICollectionElementKindSectionFooter]) {
  22. return _footerFrame;
  23. } else {
  24. return self.frame;
  25. }
  26. }
  27. - (void)callMethod:(ZLBaseEventModel*)eventModel {
  28. NSAssert([eventModel isKindOfClass:[ZLBaseEventModel class]], @"callMethod必须传入ZLBaseEventModel类型参数");
  29. if (eventModel == nil) {
  30. return;
  31. }
  32. if (eventModel.eventName != nil) {
  33. self.eventName = eventModel.eventName;
  34. }
  35. if (eventModel.parameter) {
  36. self.parameter = eventModel.parameter;
  37. }
  38. }
  39. @end