123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- //
- // KXMainListTableViewCell.m
- // QBCS
- //
- // Created by kuxuan on 2017/6/6.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXMainListTableViewCell.h"
- @implementation KXMainListTableViewCell
- {
- UIImageView *_imageView;
- UILabel *_titlelabel;
- UILabel *_labelLabel;
- UILabel *_detailLabel;
- UILabel *_applyLabel;
- UILabel *_rateLabel;
- UILabel *_amountLabel;
- UILabel *_amountTitleLabel;
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- if (self==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- [self setupUI];
- }
- return self;
- }
- -(void)setupUI
- {
- _imageView=[[UIImageView alloc]init];
- _imageView.layer.cornerRadius=8;
- _imageView.layer.masksToBounds=YES;
- [self.contentView addSubview:_imageView];
-
- _titlelabel=[[UILabel alloc]init];
- _titlelabel.font=FONT_SYS(16*SCREEN_MUTI);
- _titlelabel.textColor=[UIColor titleColor];
- [self.contentView addSubview:_titlelabel];
-
- _detailLabel=[[UILabel alloc]init];
- _detailLabel.font=FONT_SYS(12*SCREEN_MUTI);
- _detailLabel.textColor=[UIColor detailTitleColor];
- _detailLabel.textAlignment = NSTextAlignmentLeft;
- [_detailLabel sizeToFit];
- _detailLabel.numberOfLines = 0;
- [self.contentView addSubview:_detailLabel];
-
- _applyLabel=[[UILabel alloc]init];
- _applyLabel.font=FONT_SYS(12*SCREEN_MUTI);
- _applyLabel.textColor=[UIColor detailTitleColor];
- [self.contentView addSubview:_applyLabel];
-
- _rateLabel=[[UILabel alloc]init];
- _rateLabel.font=FONT_SYS(12*SCREEN_MUTI);
- _rateLabel.textColor=[UIColor detailTitleColor];
- [self.contentView addSubview:_rateLabel];
-
- _labelLabel=[[UILabel alloc]init];
- _labelLabel.textColor=[UIColor whiteColor];
- _labelLabel.textAlignment=NSTextAlignmentCenter;
- _labelLabel.backgroundColor=[UIColor KXColorWithHex:0xe42a2a];
- _labelLabel.layer.cornerRadius=4;
- _labelLabel.layer.masksToBounds=YES;
- _labelLabel.font=FONT_SYS(12*SCREEN_MUTI);
- [self.contentView addSubview:_labelLabel];
-
- _amountLabel = [[UILabel alloc] init];
- _amountLabel.textColor = [UIColor KXColorWithHex:0xE42A2A];
- _amountLabel.font = FONT_SYS(16);
- _amountLabel.textAlignment = NSTextAlignmentRight;
- [self.contentView addSubview:_amountLabel];
-
- _amountTitleLabel = [[UILabel alloc] init];
- _amountTitleLabel.textColor = [UIColor titleColor];
- _amountTitleLabel.font = FONT_SYS(10);
- _amountTitleLabel.textAlignment = NSTextAlignmentRight;
- _amountTitleLabel.text = @"额度范围(元)";
- [self.contentView addSubview:_amountTitleLabel];
-
- UIView *bottemLine=[[UILabel alloc]init];
- bottemLine.backgroundColor=[UIColor KXColorWithHex:0xe5e5e5];
- [self.contentView addSubview:bottemLine];
-
- // UILabel *topLineLabel=[[UILabel alloc]init];
- // topLineLabel.backgroundColor=[UIColor lineColor];
- // [self.contentView addSubview:topLineLabel];
-
- [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView.mas_left).offset(Fitsize(10));
- make.size.mas_equalTo(CGSizeMake(50*SCREEN_MUTI, 50*SCREEN_MUTI));
- make.centerY.equalTo(self.contentView.mas_centerY);
- }];
-
- [_titlelabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_imageView.mas_right).offset(Fitsize(10));
- make.top.equalTo(_imageView.mas_top);
- }];
-
- [_labelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_titlelabel.mas_right).offset(Fitsize(5));
- make.top.equalTo(_titlelabel.mas_top);
- make.size.equalTo(CGSizeMake(Fitsize(53), Fitsize(16)));
- }];
-
- [_applyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_titlelabel.mas_left);
- make.top.equalTo(_titlelabel.mas_bottom).offset(2);
- }];
-
- [_detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(_titlelabel.mas_left);
- make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(10));
- make.top.equalTo(_applyLabel.mas_bottom).offset(Fitsize(2));
- }];
-
- [_amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView.mas_top).offset(Fitsize(20));
- make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(25));
- }];
- [_amountTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(_amountLabel.mas_bottom);
- make.right.equalTo(_amountLabel.mas_right);
- }];
-
- [bottemLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
- make.left.equalTo(self.contentView.mas_left).offset(Fitsize(10));
- make.right.equalTo(self.contentView.mas_right).offset(-Fitsize(10));
- make.height.equalTo(@0.5);
- }];
-
- }
- -(void)setHotmodel:(KXHotList *)hotmodel
- {
- _hotmodel=hotmodel;
-
- [_imageView sd_setImageWithURL:[NSURL URLWithString:hotmodel.icon] placeholderImage:[UIImage imageNamed:@"placeholder_square"] options:SDWebImageRefreshCached];
- _titlelabel.text=hotmodel.name;
- _applyLabel.text = [NSString stringWithFormat:@"%@人申请",hotmodel.applicants];
- if ([hotmodel.show_day isEqualToString:@"日利率"]) {
- NSString *rateStr=[NSString stringWithFormat:@"%@%@ %@起",hotmodel.show_day,hotmodel.day_rate,@"%"];
- // NSMutableAttributedString *dayAtt = [[NSMutableAttributedString alloc]initWithString:rateStr];
- // [dayAtt addAttribute:NSForegroundColorAttributeName
- // value:[UIColor KXColorWithHex:0xe42a2a]
- // range:NSMakeRange(3, [rateStr length]-4)];
- // _rateLabel.attributedText = dayAtt;
- _detailLabel.text = [NSString stringWithFormat:@"%@放款 %@",hotmodel.lend_time,rateStr];
- }else{
- NSString *rateStr=[NSString stringWithFormat:@"%@%@ %@起",hotmodel.show_day,hotmodel.monthly_rate,@"%"];
- // NSMutableAttributedString *monthAtt = [[NSMutableAttributedString alloc]initWithString:rateStr];
- // [monthAtt addAttribute:NSForegroundColorAttributeName
- // value:[UIColor KXColorWithHex:0xe42a2a]
- // range:NSMakeRange(3, [rateStr length]-4)];
- _detailLabel.text = [NSString stringWithFormat:@"%@放款 %@",hotmodel.lend_time,rateStr];
- }
- _labelLabel.hidden=NO;
- [_labelLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.size.equalTo(CGSizeMake(13.5*hotmodel.prod_title.length, Fitsize(16)));
- }];
- _labelLabel.text=hotmodel.prod_title;
- _amountLabel.text = [NSString stringWithFormat:@"%@-%@",hotmodel.upper_amount,hotmodel.lower_amount];
- if (hotmodel.prod_title.length==0) {
- _labelLabel.hidden=YES;
- }
- }
- @end
|