XYSetSkillInfoTableViewCell.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // XYSetSkillInfoTableViewCell.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/10/29.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYSetSkillInfoTableViewCell.h"
  9. #import "XYSetSkillInfoCellModel.h"
  10. @interface XYSetSkillInfoTableViewCell ()
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @property (nonatomic, strong) UILabel *contentLabel;
  13. @property (nonatomic, strong) UIView *line;
  14. @end
  15. @implementation XYSetSkillInfoTableViewCell
  16. #pragma mark — Public
  17. + (instancetype)cellWithTableView:(UITableView *)tableView {
  18. static NSString *cellId = @"XYSetSkillInfoTableViewCell";
  19. XYSetSkillInfoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  20. if (cell == nil) {
  21. cell = [[XYSetSkillInfoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  22. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  23. }
  24. return cell;
  25. }
  26. - (void)configureModel:(XYSetSkillInfoCellModel *)model {
  27. self.titleLabel.text = model.title;
  28. self.contentLabel.text = model.content;
  29. self.contentLabel.textColor = model.contentColor;
  30. self.line.hidden = !model.isShowBottomLine;
  31. }
  32. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  33. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  34. [self setupUI];
  35. }
  36. return self;
  37. }
  38. - (void)setupUI {
  39. self.contentView.backgroundColor = Color_White;
  40. [self.contentView addSubview:self.titleLabel];
  41. [self.contentView addSubview:self.contentLabel];
  42. [self.contentView addSubview:self.line];
  43. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.contentView).offset(20.0f);
  45. make.centerY.equalTo(self.contentView);
  46. }];
  47. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.right.equalTo(self.contentView).offset(-20.0f);
  49. make.centerY.equalTo(self.contentView);
  50. }];
  51. [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.left.right.bottom.equalTo(self.contentView);
  53. make.height.equalTo(@(LINE_HEIGHT));
  54. }];
  55. }
  56. #pragma mark — Getter
  57. - (UILabel *)titleLabel {
  58. if (!_titleLabel) {
  59. _titleLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
  60. }
  61. return _titleLabel;
  62. }
  63. - (UILabel *)contentLabel {
  64. if (!_contentLabel) {
  65. _contentLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font(14)];
  66. _contentLabel.textAlignment = NSTextAlignmentRight;
  67. }
  68. return _contentLabel;
  69. }
  70. - (UIView *)line {
  71. if (!_line) {
  72. _line = [UIView new];
  73. _line.backgroundColor = Color_line;
  74. }
  75. return _line;
  76. }
  77. - (void)awakeFromNib {
  78. [super awakeFromNib];
  79. // Initialization code
  80. }
  81. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  82. [super setSelected:selected animated:animated];
  83. // Configure the view for the selected state
  84. }
  85. @end