CustomCollectionViewCell.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // CustomCollectionViewCell.m
  3. // CGXVerticalMenuView-OC
  4. //
  5. // Created by CGX on 2018/05/01.
  6. // Copyright © 2021 CGX. All rights reserved.
  7. //
  8. #import "CustomCollectionViewCell.h"
  9. @implementation CustomCollectionViewCell
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self initializeViews];
  15. }
  16. return self;
  17. }
  18. - (instancetype)initWithCoder:(NSCoder *)coder
  19. {
  20. self = [super initWithCoder:coder];
  21. if (self) {
  22. [self initializeViews];
  23. }
  24. return self;
  25. }
  26. - (void)initializeViews
  27. {
  28. self.titleLabel =[[UILabel alloc] init];
  29. self.titleLabel.textColor = [UIColor blackColor];
  30. self.titleLabel.font = [UIFont systemFontOfSize:14];
  31. self.titleLabel.numberOfLines = 0;
  32. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  33. [self.contentView addSubview:self.titleLabel];
  34. self.titleLabel.text = @"我是自定义cell";
  35. }
  36. - (void)layoutSubviews
  37. {
  38. [super layoutSubviews];
  39. self.titleLabel.frame = CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame));
  40. }
  41. @end