// // TFFeedBackViewCellCell.m // TFReader // // Created by 谢腾飞 on 2020/12/22. // Copyright © 2020 xtfei_2011@126.com. All rights reserved. // #import "TFFeedBackViewCellCell.h" @interface TFFeedBackViewCellCell () { UILabel *questionTitleLabel; UILabel *questionDetailLabel; } @end @implementation TFFeedBackViewCellCell - (void)createSubviews { [super createSubviews]; questionTitleLabel = [[UILabel alloc] init]; questionTitleLabel.backgroundColor = kWhiteColor; questionTitleLabel.textColor = kBlackColor; questionTitleLabel.font = kMainFont; questionTitleLabel.numberOfLines = 0; questionTitleLabel.userInteractionEnabled = YES; [self.contentView addSubview:questionTitleLabel]; [questionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin); make.top.mas_equalTo(self.contentView.mas_top); make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin); make.height.mas_equalTo(40); }]; questionDetailLabel = [[UILabel alloc] init]; questionDetailLabel.textColor = kGrayTextColor; questionDetailLabel.font = kMainFont; questionDetailLabel.numberOfLines = 0; [self.contentView addSubview:questionDetailLabel]; [questionDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(questionTitleLabel.mas_left).with.offset(kHalfMargin); make.top.mas_equalTo(questionTitleLabel.mas_bottom); make.right.mas_equalTo(questionTitleLabel.mas_right).with.offset(- kHalfMargin); make.height.mas_equalTo(CGFLOAT_MIN); make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow(); }]; } - (void)setQuestionModel:(TFQuestionListModel *)questionModel { _questionModel = questionModel; questionTitleLabel.text = [NSString stringWithFormat:@"Q:%@", questionModel.title]?:@""; [questionTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - kMargin) labelText:questionTitleLabel.text]); }]; questionDetailLabel.text = [NSString stringWithFormat:@"A:%@", questionModel.answer]?:@""; } - (void)showDetail { self.detailCellShowing = YES; [UIView animateWithDuration:kAnimatedDurationFast animations:^{ [self->questionDetailLabel mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabel:self->questionDetailLabel] - kHalfMargin); }]; [self->questionDetailLabel.superview layoutIfNeeded];//强制绘制 }]; } - (void)hiddenDetail { self.detailCellShowing = NO; [UIView animateWithDuration:kAnimatedDurationFast animations:^{ [self->questionDetailLabel mas_updateConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(CGFLOAT_MIN); }]; [self->questionDetailLabel.superview layoutIfNeeded];//强制绘制 }]; } @end