CGXVerticalMenuTitleCell.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // CGXVerticalMenuTitleCell.m
  3. // CGXVerticalMenuView-OC
  4. //
  5. // Created by CGX on 2018/05/01.
  6. // Copyright © 2019 CGX. All rights reserved.
  7. //
  8. #import "CGXVerticalMenuTitleCell.h"
  9. @interface CGXVerticalMenuTitleCell()
  10. @property (nonatomic , strong) UILabel *titleLabel;
  11. @end
  12. @implementation CGXVerticalMenuTitleCell
  13. - (void)initializeViews
  14. {
  15. [super initializeViews];
  16. self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame))];
  17. self.titleLabel.textAlignment = NSTextAlignmentCenter;
  18. [self.contentView addSubview:self.titleLabel];
  19. [self.contentView sendSubviewToBack:self.titleLabel];
  20. }
  21. - (void)layoutSubviews
  22. {
  23. [super layoutSubviews];
  24. self.titleLabel.frame = CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame));
  25. }
  26. - (void)reloadData:(CGXVerticalMenuBaseModel *)model
  27. {
  28. [super reloadData:model];
  29. CGXVerticalMenuTitleModel *cellModel = (CGXVerticalMenuTitleModel *)model;
  30. self.titleLabel.text = cellModel.title;
  31. if (cellModel.isSelected) {
  32. self.titleLabel.textColor = cellModel.titleSelectedColor;
  33. self.titleLabel.font = cellModel.titleSelectedFont;
  34. } else{
  35. self.titleLabel.textColor = cellModel.titleNormalColor;
  36. self.titleLabel.font = cellModel.titleFont;
  37. }
  38. }
  39. @end