口袋优选

KBMessageListCell.m 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // KBMessageListCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/21.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBMessageListCell.h"
  9. @interface KBMessageListCell ()
  10. @property (nonatomic, strong) UIView *bgView;
  11. @property (nonatomic, strong) UILabel *dateLabel;
  12. @property (nonatomic, strong) UILabel *title;
  13. @property (nonatomic, strong) UILabel *desLabel;
  14. @property (nonatomic, strong) UIImageView *arrowIcon;
  15. @end
  16. @implementation KBMessageListCell
  17. + (instancetype)cellWithTableView:(UITableView *)tableView {
  18. static NSString *cellID = nil;
  19. cellID = NSStringFromClass([self class]);
  20. KBMessageListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  21. if (!cell) {
  22. cell = [[KBMessageListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  23. }
  24. return cell;
  25. }
  26. - (void)awakeFromNib {
  27. [super awakeFromNib];
  28. // Initialization code
  29. }
  30. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  31. [super setSelected:selected animated:animated];
  32. // Configure the view for the selected state
  33. }
  34. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  35. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  36. if (self) {
  37. self.backgroundColor = [UIColor YHColorWithHex:0xf4f4f4];
  38. self.selectionStyle = UITableViewCellSelectionStyleNone;
  39. [self initSubViews];
  40. }
  41. return self;
  42. }
  43. - (void)initSubViews {
  44. [self.contentView addSubview:self.dateLabel];
  45. [self.contentView addSubview:self.bgView];
  46. [self.bgView addSubview:self.title];
  47. [self.bgView addSubview:self.desLabel];
  48. [self.bgView addSubview:self.arrowIcon];
  49. [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(10);
  51. make.top.mas_equalTo(14);
  52. }];
  53. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(10);
  55. make.right.mas_equalTo(-10);
  56. make.top.mas_equalTo(39);
  57. make.bottom.mas_equalTo(0);
  58. }];
  59. [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.mas_equalTo(15);
  61. make.left.mas_equalTo(15);
  62. make.height.mas_equalTo(24);
  63. }];
  64. [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.width.height.mas_equalTo(24);
  66. make.right.mas_equalTo(-18);
  67. make.centerY.mas_equalTo(self.title);
  68. }];
  69. [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.mas_equalTo(self.title);
  71. make.right.mas_equalTo(-15);
  72. make.top.mas_equalTo(self.title.mas_bottom).mas_offset(5);
  73. }];
  74. }
  75. - (void)setModel:(KBMessageModel *)model {
  76. _model = model;
  77. self.title.text = model.title;
  78. self.desLabel.text = model.message;
  79. self.title.textColor = [model.is_view isEqualToString:@"1"] ? [UIColor YHColorWithHex:0x999999] : [UIColor YHColorWithHex:0x333333];
  80. self.desLabel.textColor = [model.is_view isEqualToString:@"1"] ? [UIColor YHColorWithHex:0x999999] : [UIColor YHColorWithHex:0x333333];
  81. self.dateLabel.text = model.push_at;
  82. }
  83. - (void)isRead {
  84. self.title.textColor = [UIColor YHColorWithHex:0x999999];
  85. self.desLabel.textColor = [UIColor YHColorWithHex:0x999999];
  86. }
  87. #pragma mark -----
  88. - (UIView *)bgView {
  89. if (!_bgView) {
  90. _bgView = [[UIView alloc] init];
  91. _bgView.backgroundColor = [UIColor whiteColor];
  92. _bgView.layer.cornerRadius = 6;
  93. }
  94. return _bgView;
  95. }
  96. - (UILabel *)dateLabel {
  97. if (!_dateLabel) {
  98. _dateLabel = [[UILabel alloc] init];
  99. _dateLabel.textColor = [UIColor YHColorWithHex:0x999999];
  100. _dateLabel.font = [UIFont systemFontOfSize:12];
  101. }
  102. return _dateLabel;
  103. }
  104. - (UILabel *)title {
  105. if (!_title) {
  106. _title = [[UILabel alloc] init];
  107. _title.font = [UIFont systemFontOfSize:16];
  108. _title.textColor = [UIColor YHColorWithHex:0x333333];
  109. _title.text = @"热门爆款";
  110. }
  111. return _title;
  112. }
  113. - (UILabel *)desLabel {
  114. if (!_desLabel) {
  115. _desLabel = [[UILabel alloc] init];
  116. _desLabel.font = [UIFont systemFontOfSize:14];
  117. _desLabel.textColor = [UIColor YHColorWithHex:0x666666];
  118. _desLabel.text = @"福建阿附近阿克苏金卡价撒蛟龙卡聚隆科技";
  119. }
  120. return _desLabel;
  121. }
  122. - (UIImageView *)arrowIcon {
  123. if (!_arrowIcon) {
  124. _arrowIcon = [[UIImageView alloc] init];
  125. _arrowIcon.image = [UIImage imageNamed:@"more_acc"];
  126. }
  127. return _arrowIcon;
  128. }
  129. @end