Geen omschrijving

KXMainListTableViewCell.m 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // KXMainListTableViewCell.m
  3. // QBCS
  4. //
  5. // Created by kuxuan on 2017/6/6.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXMainListTableViewCell.h"
  9. @implementation KXMainListTableViewCell
  10. {
  11. UIImageView *_imageView;
  12. UILabel *_titlelabel;
  13. UILabel *_labelLabel;
  14. UILabel *_detailLabel;
  15. UILabel *_applyLabel;
  16. UILabel *_rateLabel;
  17. UILabel *_amountLabel;
  18. UILabel *_amountTitleLabel;
  19. }
  20. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  21. {
  22. if (self==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  23. [self setupUI];
  24. }
  25. return self;
  26. }
  27. -(void)setupUI
  28. {
  29. _imageView=[[UIImageView alloc]init];
  30. _imageView.layer.cornerRadius=8;
  31. _imageView.layer.masksToBounds=YES;
  32. [self.contentView addSubview:_imageView];
  33. _titlelabel=[[UILabel alloc]init];
  34. _titlelabel.font=FONT_SYS(16*SCREEN_MUTI);
  35. _titlelabel.textColor=[UIColor titleColor];
  36. [self.contentView addSubview:_titlelabel];
  37. _detailLabel=[[UILabel alloc]init];
  38. _detailLabel.font=FONT_SYS(12*SCREEN_MUTI);
  39. _detailLabel.textColor=[UIColor detailTitleColor];
  40. _detailLabel.textAlignment = NSTextAlignmentLeft;
  41. [_detailLabel sizeToFit];
  42. _detailLabel.numberOfLines = 0;
  43. [self.contentView addSubview:_detailLabel];
  44. _applyLabel=[[UILabel alloc]init];
  45. _applyLabel.font=FONT_SYS(12*SCREEN_MUTI);
  46. _applyLabel.textColor=[UIColor detailTitleColor];
  47. [self.contentView addSubview:_applyLabel];
  48. _rateLabel=[[UILabel alloc]init];
  49. _rateLabel.font=FONT_SYS(12*SCREEN_MUTI);
  50. _rateLabel.textColor=[UIColor detailTitleColor];
  51. [self.contentView addSubview:_rateLabel];
  52. _labelLabel=[[UILabel alloc]init];
  53. _labelLabel.textColor=[UIColor whiteColor];
  54. _labelLabel.textAlignment=NSTextAlignmentCenter;
  55. _labelLabel.backgroundColor=[UIColor KXColorWithHex:0xe42a2a];
  56. _labelLabel.layer.cornerRadius=4;
  57. _labelLabel.layer.masksToBounds=YES;
  58. _labelLabel.font=FONT_SYS(12*SCREEN_MUTI);
  59. [self.contentView addSubview:_labelLabel];
  60. _amountLabel = [[UILabel alloc] init];
  61. _amountLabel.textColor = [UIColor KXColorWithHex:0xE42A2A];
  62. _amountLabel.font = FONT_SYS(16);
  63. _amountLabel.textAlignment = NSTextAlignmentRight;
  64. [self.contentView addSubview:_amountLabel];
  65. _amountTitleLabel = [[UILabel alloc] init];
  66. _amountTitleLabel.textColor = [UIColor titleColor];
  67. _amountTitleLabel.font = FONT_SYS(10);
  68. _amountTitleLabel.textAlignment = NSTextAlignmentRight;
  69. _amountTitleLabel.text = @"额度范围(元)";
  70. [self.contentView addSubview:_amountTitleLabel];
  71. UIView *bottemLine=[[UILabel alloc]init];
  72. bottemLine.backgroundColor=[UIColor KXColorWithHex:0xe5e5e5];
  73. [self.contentView addSubview:bottemLine];
  74. // UILabel *topLineLabel=[[UILabel alloc]init];
  75. // topLineLabel.backgroundColor=[UIColor lineColor];
  76. // [self.contentView addSubview:topLineLabel];
  77. [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.equalTo(self.contentView.mas_left).offset(Fitsize(10));
  79. make.size.mas_equalTo(CGSizeMake(50*SCREEN_MUTI, 50*SCREEN_MUTI));
  80. make.centerY.equalTo(self.contentView.mas_centerY);
  81. }];
  82. [_titlelabel mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.equalTo(_imageView.mas_right).offset(Fitsize(10));
  84. make.top.equalTo(_imageView.mas_top);
  85. }];
  86. [_labelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.left.equalTo(_titlelabel.mas_right).offset(Fitsize(5));
  88. make.top.equalTo(_titlelabel.mas_top);
  89. make.size.equalTo(CGSizeMake(Fitsize(53), Fitsize(16)));
  90. }];
  91. [_applyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.left.equalTo(_titlelabel.mas_left);
  93. make.top.equalTo(_titlelabel.mas_bottom).offset(2);
  94. }];
  95. [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.equalTo(_titlelabel.mas_left);
  97. make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(10));
  98. make.top.equalTo(_applyLabel.mas_bottom).offset(Fitsize(2));
  99. }];
  100. [_amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.top.equalTo(self.contentView.mas_top).offset(Fitsize(20));
  102. make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(25));
  103. }];
  104. [_amountTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.top.equalTo(_amountLabel.mas_bottom);
  106. make.right.equalTo(_amountLabel.mas_right);
  107. }];
  108. [bottemLine mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
  110. make.left.equalTo(self.contentView.mas_left).offset(Fitsize(10));
  111. make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(10));
  112. make.height.equalTo(@0.5);
  113. }];
  114. }
  115. -(void)setHotmodel:(KXHotList *)hotmodel
  116. {
  117. _hotmodel=hotmodel;
  118. [_imageView sd_setImageWithURL:[NSURL URLWithString:hotmodel.icon] placeholderImage:[UIImage imageNamed:@"placeholder_square"] options:SDWebImageRefreshCached];
  119. _titlelabel.text=hotmodel.name;
  120. _applyLabel.text = [NSString stringWithFormat:@"%@人申请",hotmodel.applicants];
  121. if ([hotmodel.show_day isEqualToString:@"日利率"]) {
  122. NSString *rateStr=[NSString stringWithFormat:@"%@%@ %@起",hotmodel.show_day,hotmodel.day_rate,@"%"];
  123. // NSMutableAttributedString *dayAtt = [[NSMutableAttributedString alloc]initWithString:rateStr];
  124. // [dayAtt addAttribute:NSForegroundColorAttributeName
  125. // value:[UIColor KXColorWithHex:0xe42a2a]
  126. // range:NSMakeRange(3, [rateStr length]-4)];
  127. // _rateLabel.attributedText = dayAtt;
  128. _detailLabel.text = [NSString stringWithFormat:@"%@放款 %@",hotmodel.lend_time,rateStr];
  129. }else{
  130. NSString *rateStr=[NSString stringWithFormat:@"%@%@ %@起",hotmodel.show_day,hotmodel.monthly_rate,@"%"];
  131. // NSMutableAttributedString *monthAtt = [[NSMutableAttributedString alloc]initWithString:rateStr];
  132. // [monthAtt addAttribute:NSForegroundColorAttributeName
  133. // value:[UIColor KXColorWithHex:0xe42a2a]
  134. // range:NSMakeRange(3, [rateStr length]-4)];
  135. _detailLabel.text = [NSString stringWithFormat:@"%@放款 %@",hotmodel.lend_time,rateStr];
  136. }
  137. _labelLabel.hidden=NO;
  138. [_labelLabel mas_updateConstraints:^(MASConstraintMaker *make) {
  139. make.size.equalTo(CGSizeMake(13.5*hotmodel.prod_title.length, Fitsize(16)));
  140. }];
  141. _labelLabel.text=hotmodel.prod_title;
  142. _amountLabel.text = [NSString stringWithFormat:@"%@-%@",hotmodel.upper_amount,hotmodel.lower_amount];
  143. if (hotmodel.prod_title.length==0) {
  144. _labelLabel.hidden=YES;
  145. }
  146. }
  147. @end