// // KBSignInTableViewCell.m // YouHuiProject // // Created by jcymac on 2018/10/12. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBSignInTableViewCell.h" @implementation KBSignInTableViewCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor clearColor]; self.contentView.backgroundColor = [UIColor clearColor]; [self makeUI]; } return self; } - (void)makeUI { [self.contentView addSubview:self.lineView]; self.leftImageView = [[UIImageView alloc]init]; [self.contentView addSubview:self.leftImageView]; [self.contentView addSubview:self.contentLable]; [self.contentView addSubview:self.rightBtn]; [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(FITSIZE(15)); make.right.mas_equalTo(-FITSIZE(15)); make.top.mas_equalTo(0); make.height.mas_equalTo(1); }]; [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(FITSIZE(13)); make.width.mas_equalTo(FITSIZE(43)); make.height.mas_equalTo(FITSIZE(50)); make.centerY.mas_equalTo(self.contentView.mas_centerY); }]; [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-FITSIZE(10)); make.width.mas_equalTo(FITSIZE(90)); make.height.mas_equalTo(FITSIZE(30)); make.centerY.mas_equalTo(self.contentView.mas_centerY); }]; [self.contentLable mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.leftImageView.mas_right).offset(FITSIZE(10)); make.right.mas_equalTo(self.rightBtn.mas_left).offset(5); make.height.mas_equalTo(20); make.centerY.mas_equalTo(self.contentView.mas_centerY); }]; } - (UIButton*)rightBtn { if (!_rightBtn) { _rightBtn = [[UIButton alloc]init]; _rightBtn.layer.borderWidth = 1; _rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor; _rightBtn.layer.masksToBounds = YES; _rightBtn.layer.cornerRadius = FITSIZE(16); } return _rightBtn; } - (UILabel *)contentLable { if (!_contentLable) { _contentLable = [[UILabel alloc] init]; _contentLable.textColor = [UIColor colorWithHexString:@"#F9041C"]; _contentLable.font = [UIFont systemFontOfSize:16]; } return _contentLable; } - (UIView *)lineView { if (!_lineView) { _lineView = [[UIView alloc]init]; _lineView.backgroundColor = [UIColor colorWithHexString:@"#F9B37F"]; _lineView.hidden = YES; } return _lineView; } - (void)refreshCellWithModel:(KBSignDetailModel *)detailModel andIndexPath:(NSIndexPath*)index { if (index.row != 0) { _lineView.hidden = NO; } [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.img] placeholderImage:nil]; if (detailModel.postion) { NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:detailModel.content]; [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0f] range:NSMakeRange([detailModel.postion[@"pos"] intValue],[detailModel.postion[@"len"] intValue])]; [self.contentLable setAttributedText:attrStr]; }else { self.contentLable.text = detailModel.content; } [[self.rightBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) { [self.clickDelegate clickCellIndexPath:index]; }]; if (detailModel.type == 1) { self.rightBtn.backgroundColor = [UIColor colorWithHexString:@"#FF7E00"]; self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:14]; self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor; [self.rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; self.rightBtn.enabled = YES; [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal]; }else if (detailModel.type == 0){ self.rightBtn.backgroundColor = [UIColor clearColor]; self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:10]; self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#FF5266"].CGColor; [self.rightBtn setTitleColor:[UIColor colorWithHexString:@"#FF5266"] forState:UIControlStateNormal]; self.rightBtn.enabled = NO; [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal]; }else { self.rightBtn.backgroundColor = [UIColor clearColor]; self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:10]; self.rightBtn.layer.borderColor = [UIColor colorWithHexString:@"#F9041C"].CGColor; [self.rightBtn setTitleColor:[UIColor colorWithHexString:@"#F9041C"] forState:UIControlStateNormal]; self.rightBtn.enabled = NO; [self.rightBtn setTitle:detailModel.time_describe forState:UIControlStateNormal]; } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end