YOUPAITFBaseCollectionCell.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // YOUPAITFBaseCollectionCell.m
  3. // trueface
  4. //
  5. // Created by Apple on 2019/10/10.
  6. // Copyright © 2019 jie. All rights reserved.
  7. //
  8. #import "YOUPAITFBaseCollectionCell.h"
  9. @interface YOUPAITFBaseCollectionCell()
  10. @end
  11. @implementation YOUPAITFBaseCollectionCell
  12. +(instancetype)youpaifcellWithCollectionViewCell:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath
  13. {
  14. NSString *className = NSStringFromClass([self class]);
  15. id rigistedClass = objc_getAssociatedObject(self, (__bridge const void * _Nonnull)(className));
  16. if (!rigistedClass) {
  17. [collectionView registerClass:[self class] forCellWithReuseIdentifier:className];
  18. rigistedClass = NSStringFromClass([self class]);
  19. objc_setAssociatedObject(self, (__bridge const void * _Nonnull)(className), rigistedClass, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
  20. }
  21. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:className forIndexPath:indexPath];
  22. return (YOUPAITFBaseCollectionCell *)cell;
  23. }
  24. -(instancetype)initWithFrame:(CGRect)frame
  25. {
  26. self = [super initWithFrame:frame];
  27. if (self)
  28. {
  29. [self youpaifsetupUI];
  30. }
  31. return self;
  32. }
  33. -(void)youpaifsetupUI
  34. {
  35. }
  36. @end