ASPointDetailCell.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // ASPointDetailCell.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/24.
  6. //
  7. #import "ASPointDetailCell.h"
  8. @interface ASPointDetailCell ()
  9. @property (nonatomic, strong) UIView *bgV;
  10. @property (nonatomic, strong) UIView *lineV;
  11. @property (nonatomic, strong) UILabel *titleLb;
  12. @property (nonatomic, strong) UILabel *pointsLb;
  13. @property (nonatomic, strong) UILabel *elsePointsLb;
  14. @property (nonatomic, strong) UILabel *dateLb;
  15. @end
  16. @implementation ASPointDetailCell
  17. - (void)setData:(ASPointDetailModel *)model {
  18. self.titleLb.text = model.title;
  19. self.dateLb.text = model.time;
  20. self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.point];
  21. self.elsePointsLb.text = [NSString stringWithFormat:@"My points:%@",model.elsePoint];
  22. }
  23. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  24. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  25. if (self) {
  26. [self confgSubV];
  27. }
  28. return self;
  29. }
  30. - (void)awakeFromNib {
  31. [super awakeFromNib];
  32. // Initialization code
  33. }
  34. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  35. [super setSelected:selected animated:animated];
  36. // Configure the view for the selected state
  37. }
  38. - (void)confgSubV {
  39. self.selectionStyle = UITableViewCellSelectionStyleNone;
  40. self.contentView.backgroundColor = [UIColor whiteColor];
  41. [self.contentView addSubview:self.bgV];
  42. [self.bgV addSubview:self.titleLb];
  43. [self.bgV addSubview:self.pointsLb];
  44. [self.bgV addSubview:self.elsePointsLb];
  45. [self.bgV addSubview:self.dateLb];
  46. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.edges.equalTo(self.contentView);
  48. make.height.equalTo(@80);
  49. }];
  50. [self.bgV addSubview:self.lineV];
  51. [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.height.equalTo(@1);
  53. make.leading.equalTo(self.bgV).offset(10);
  54. make.trailing.equalTo(self.bgV).offset(-10);
  55. make.bottom.equalTo(self.bgV);
  56. }];
  57. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.bgV).offset(10);
  59. make.top.equalTo(self.bgV).offset(20);
  60. make.height.greaterThanOrEqualTo(@17);
  61. }];
  62. [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.equalTo(self.bgV).offset(10);
  64. make.height.equalTo(@14);
  65. make.bottom.equalTo(self.bgV).offset(-20);
  66. }];
  67. [self.pointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  68. [self.pointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.right.equalTo(self.bgV.mas_right).offset(-10);
  70. make.left.equalTo(self.titleLb.mas_right).offset(30);
  71. make.top.equalTo(self.titleLb);
  72. make.height.equalTo(@14);
  73. make.width.greaterThanOrEqualTo(@60);
  74. }];
  75. [self.elsePointsLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  76. [self.elsePointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.right.equalTo(self.bgV.mas_right).offset(-10);
  78. make.left.equalTo(self.dateLb.mas_right).offset(30);
  79. make.centerY.equalTo(self.dateLb);
  80. make.height.equalTo(@14);
  81. }];
  82. }
  83. - (UILabel *)titleLb {
  84. if (!_titleLb) {
  85. UILabel *lb = [UILabel new];
  86. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  87. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  88. lb.numberOfLines = 0;
  89. _titleLb = lb;
  90. }
  91. return _titleLb;
  92. }
  93. - (UILabel *)pointsLb {
  94. if (!_pointsLb) {
  95. UILabel *lb = [UILabel new];
  96. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:1];
  97. lb.textAlignment = NSTextAlignmentRight;
  98. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  99. lb.numberOfLines = 1;
  100. [lb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
  101. _pointsLb = lb;
  102. }
  103. return _pointsLb;
  104. }
  105. - (UILabel *)elsePointsLb {
  106. if (!_elsePointsLb) {
  107. UILabel *lb = [UILabel new];
  108. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  109. lb.textAlignment = NSTextAlignmentRight;
  110. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  111. lb.numberOfLines = 1;
  112. _elsePointsLb = lb;
  113. }
  114. return _elsePointsLb;
  115. }
  116. - (UILabel *)dateLb {
  117. if (!_dateLb) {
  118. UILabel *lb = [UILabel new];
  119. lb.textColor = [[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.6];
  120. lb.textAlignment = NSTextAlignmentLeft;
  121. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  122. lb.numberOfLines = 1;
  123. _dateLb = lb;
  124. }
  125. return _dateLb;
  126. }
  127. -(UIView *)bgV {
  128. if (!_bgV) {
  129. UIView *v = [UIView new];
  130. v.backgroundColor = Col_FFF;
  131. _bgV = v;
  132. }
  133. return _bgV;
  134. }
  135. -(UIView *)lineV {
  136. if (!_lineV) {
  137. UIView *v = [UIView new];
  138. v.backgroundColor = [_043632 colorWithAlphaComponent:0.1];
  139. _lineV = v;
  140. }
  141. return _lineV;
  142. }
  143. @end