XYModifyInfoSectionTableViewCell.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // XYModifyInfoSectionTableViewCell.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/3/30.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYModifyInfoSectionTableViewCell.h"
  9. #import "XYModifyUserInfoListModel.h"
  10. @interface XYModifyInfoSectionTableViewCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *titleLabel;
  12. @property (nonatomic, readwrite, strong) UILabel *descLabel;
  13. @end
  14. @implementation XYModifyInfoSectionTableViewCell
  15. #pragma mark - Public Method
  16. + (instancetype)cellWithTableView:(UITableView *)tableView {
  17. static NSString * const cellId = @"XYModifyInfoSectionTableViewCell";
  18. XYModifyInfoSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  19. if (cell == nil) {
  20. cell = [[XYModifyInfoSectionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  21. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return cell;
  24. }
  25. - (void)configureModel:(XYModifyUserInfoListModel *)model {
  26. self.titleLabel.text = model.groupName;
  27. if (model.userInfoType == ModifyUserInfo_Type_Main) {
  28. self.backgroundColor = Color_White;
  29. self.descLabel.hidden = YES;
  30. self.titleLabel.textColor = [UIColor colorWithHexString:@"#313233" alpha:1];
  31. self.titleLabel.font = Font_B(16);
  32. [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  33. make.left.equalTo(self.contentView).offset(SPACING_EDGE);
  34. make.bottom.equalTo(self.contentView);
  35. }];
  36. }else{
  37. self.titleLabel.textColor = Color_TextGray;
  38. self.titleLabel.font = Font(14);
  39. self.descLabel.hidden = NO;
  40. self.descLabel.text = [NSString stringWithFormat:@"%ld%@完成",(long)model.groupScore,@"%"];
  41. if (model.groupScore < 0) {
  42. self.descLabel.hidden = YES;
  43. }else{
  44. self.descLabel.hidden = NO;
  45. }
  46. }
  47. }
  48. #pragma mark - 初始化
  49. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  50. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  51. // 初始化
  52. [self _setup];
  53. // 创建自控制器
  54. [self _setupSubViews];
  55. // 布局子控件
  56. [self _makeSubViewsConstraints];
  57. }
  58. return self;
  59. }
  60. #pragma mark - 事件处理Or辅助方法
  61. #pragma mark - Private Method
  62. - (void)_setup{
  63. self.backgroundColor = Color_Background;
  64. }
  65. #pragma mark - 创建子控件
  66. - (void)_setupSubViews{
  67. [self.contentView addSubview:self.titleLabel];
  68. [self.contentView addSubview:self.descLabel];
  69. }
  70. #pragma mark - 布局子控件
  71. - (void)_makeSubViewsConstraints{
  72. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(self.contentView).offset(SPACING_EDGE);
  74. make.centerY.equalTo(self.contentView);
  75. make.width.lessThanOrEqualTo(@150.0f);
  76. }];
  77. [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.equalTo(self.titleLabel.mas_right).offset(10);
  79. make.centerY.equalTo(self.contentView);
  80. make.right.lessThanOrEqualTo(self.contentView).offset(-SPACING_EDGE);
  81. }];
  82. }
  83. - (void)awakeFromNib {
  84. [super awakeFromNib];
  85. // Initialization code
  86. }
  87. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  88. [super setSelected:selected animated:animated];
  89. // Configure the view for the selected state
  90. }
  91. - (UILabel *)titleLabel {
  92. if (!_titleLabel) {
  93. _titleLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font(14)];
  94. }
  95. return _titleLabel;
  96. }
  97. - (UILabel *)descLabel {
  98. if (!_descLabel) {
  99. _descLabel = [UILabel createLabelTextColor:Color_TextGray fount:Font(11)];
  100. }
  101. return _descLabel;
  102. }
  103. @end