// // XYModifyInputTextTableViewCell.m // Timi // // Created by gy on 2021/3/4. // #import "XYModifyAnswerTableViewCell.h" #import "XYModifyUserInfoListModel.h" #import "XYModifyAnswerQuestionViewController.h" @interface XYModifyAnswerTableViewCell (){ } @property (nonatomic, strong) UIImageView *questionImgView; @property (nonatomic, strong) UILabel *questionLab; @property (nonatomic, strong) UIImageView *answerImgView; @property (nonatomic, strong) UILabel *answerLab; @property (nonatomic, strong) UIView *withoutView; @property (nonatomic, strong) UIImageView *moreImageView; @property (nonatomic, strong) XYModifyUserInfoListModel *model; @end @implementation XYModifyAnswerTableViewCell #pragma mark - Public Method + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString * const cellId = @"XYModifyAnswerTableViewCell"; XYModifyAnswerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (cell == nil) { cell = [[XYModifyAnswerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)configureModel:(XYModifyUserInfoListModel *)model { self.model = model; // if (StringIsEmpty(model.itemValue)) { // self.withoutView.hidden = NO; // self.questionImgView.hidden = YES; // self.questionLab.hidden = YES; // self.answerImgView.hidden = YES; // self.answerLab.hidden = YES; // }else{ self.withoutView.hidden = YES; self.questionImgView.hidden = NO; self.questionLab.hidden = NO; self.answerImgView.hidden = NO; self.answerLab.hidden = NO; self.questionImgView.image = [UIImage imageNamed:@"icon_user_question"]; self.questionLab.text = model.itemName; self.answerImgView.image = [UIImage imageNamed:@"icon_user_answer"]; self.answerLab.text = model.itemValue; // } if (model.userInfoType == ModifyUserInfo_Type_Main) { self.moreImageView.hidden = YES; }else{ self.moreImageView.hidden = NO; } } #pragma mark - 初始化 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { // 初始化 [self _setup]; } return self; } #pragma mark - 事件处理Or辅助方法 - (void)withoutViewAction{ XYModifyAnswerQuestionViewController *controller = XYModifyAnswerQuestionViewController.new; controller.model = self.model; [self.viewController.navigationController pushViewController:controller animated:YES]; } #pragma mark - Private Method - (void)_setup{ self.backgroundColor = Color_White; } - (UIImageView *)questionImgView{ if (_questionImgView == nil) { _questionImgView = [[UIImageView alloc] init]; _questionImgView.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:_questionImgView]; [_questionImgView mas_makeConstraints:^(MASConstraintMaker *make) {; make.left.equalTo(self.contentView.mas_left).offset(20); make.top.equalTo(self.contentView.mas_top).offset(8); make.width.offset(16); make.height.offset(16); }]; [_questionImgView layoutIfNeeded]; } return _questionImgView; } - (UILabel *)questionLab{ if (_questionLab == nil) { _questionLab = [[UILabel alloc] init]; _questionLab.text = @" "; _questionLab.textAlignment = NSTextAlignmentLeft; _questionLab.textColor = [UIColor colorWithHexString:@"#303133" alpha:1]; _questionLab.font = [UIFont fontWithName:kPFSCFont size:14]; _questionLab.numberOfLines = 0; [_questionLab sizeToFit]; [self.contentView addSubview:_questionLab]; [_questionLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.questionImgView.mas_right).offset(8); make.right.equalTo(self.contentView.mas_right).offset(-40); make.top.equalTo(self.questionImgView.mas_top).offset(-2); }]; [_questionLab layoutIfNeeded]; } return _questionLab; } - (UIImageView *)answerImgView{ if (_answerImgView == nil) { _answerImgView = [[UIImageView alloc] init]; _answerImgView.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:_answerImgView]; [_answerImgView mas_makeConstraints:^(MASConstraintMaker *make) {; make.left.equalTo(self.contentView.mas_left).offset(20); make.top.equalTo(self.questionLab.mas_bottom).offset(6); make.width.offset(16); make.height.offset(16); }]; [_answerImgView layoutIfNeeded]; } return _answerImgView; } - (UILabel *)answerLab{ if (_answerLab == nil) { _answerLab = [[UILabel alloc] init]; _answerLab.text = @" "; _answerLab.textAlignment = NSTextAlignmentLeft; _answerLab.textColor = [UIColor colorWithHexString:@"#606266" alpha:1]; _answerLab.font = [UIFont fontWithName:kPFSCFont size:14]; _answerLab.numberOfLines = 0; [_answerLab sizeToFit]; [self.contentView addSubview:_answerLab]; [_answerLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.answerImgView.mas_right).offset(8); make.right.equalTo(self.contentView.mas_right).offset(-40); make.top.equalTo(self.answerImgView.mas_top).offset(-2); }]; [_answerLab layoutIfNeeded]; } return _answerLab; } - (UIView *)withoutView{ if (_withoutView == nil) { _withoutView = [[UIView alloc] init]; _withoutView.backgroundColor = [UIColor clearColor]; [self.contentView addSubview:_withoutView]; [_withoutView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentView); }]; [_withoutView layoutIfNeeded]; UIImageView *imgView = [[UIImageView alloc] init]; imgView.image = [UIImage imageNamed:@"icon_nodata_answer"]; imgView.contentMode = UIViewContentModeScaleAspectFill; [_withoutView addSubview:imgView]; [imgView mas_makeConstraints:^(MASConstraintMaker *make) {; make.top.equalTo(_withoutView.mas_top).offset(15); make.centerX.equalTo(_withoutView.mas_centerX).offset(0); make.width.offset(120); make.height.offset(120); }]; [imgView layoutIfNeeded]; UILabel *_titlelab = [[UILabel alloc] init]; _titlelab.text = @"添加你感兴趣的问答,让Ta更了解你"; _titlelab.textAlignment = NSTextAlignmentLeft; _titlelab.textColor = [UIColor colorWithHexString:@"#303133" alpha:1]; _titlelab.font = [UIFont fontWithName:kPFSCFont size:14]; [_titlelab sizeToFit]; [_withoutView addSubview:_titlelab]; [_titlelab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(_withoutView.mas_centerX).offset(0); make.top.equalTo(imgView.mas_bottom).offset(20); }]; [_titlelab layoutIfNeeded]; UILabel *btnLab = [[UILabel alloc] init]; btnLab.text = @"+ 添加问答"; btnLab.textAlignment = NSTextAlignmentCenter; btnLab.textColor = [UIColor colorWithHexString:@"#FFFFFF" alpha:1]; btnLab.font = [UIFont fontWithName:kPFSCFont size:14]; btnLab.backgroundColor = [UIColor colorGradientChangeWithSize:CGSizeMake(110, 40.0f) direction:GradientChangeDirectionLevel startColor:ColorFromHexString(@"#5D26FF") endColor:ColorFromHexString(@"#9059FF")]; [btnLab sizeToFit]; [_withoutView addSubview:btnLab]; [btnLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(_withoutView.mas_centerX).offset(0); make.top.equalTo(_titlelab.mas_bottom).offset(18); make.width.offset(110); make.height.offset(40); }]; [btnLab layoutIfNeeded]; kViewRadius(btnLab, 20); UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(withoutViewAction)]; _withoutView.userInteractionEnabled = YES; [_withoutView addGestureRecognizer:tap]; } return _withoutView; } - (UIImageView *)moreImageView{ if (_moreImageView == nil) { _moreImageView = [[UIImageView alloc] init]; _moreImageView.image = arrowMore(); _moreImageView.contentMode = UIViewContentModeScaleAspectFill; [self.contentView addSubview:_moreImageView]; [_moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {; [self.moreImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.contentView).offset(-SPACING_EDGE); make.top.equalTo(self.questionImgView.mas_bottom).offset(0); make.width.equalTo(@6.0f); make.height.equalTo(@10.0f); }]; }]; [_moreImageView layoutIfNeeded]; } return _moreImageView; } - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end