// // msgAnswerQuoCell.m // ThePaperBase // // Created by YoungLee on 15/11/18. // Copyright © 2015年 scar1900. All rights reserved. // #import "msgAnswerQuoCell.h" @implementation msgAnswerQuoCell @synthesize commentBO = _commentBO; -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.lineView.hidden = YES; } return self; } - (void)setCommentBO:(commentObjectVO *)data { _commentBO = data; self.quoNameLable.text = @"我:"; self.quoContentLabel.text = data.content; self.quoContentHeight = (int)data.labelHeight; CGFloat twoLine = getLineHeightWithCountAndFontWidth(2, 10, TEXT_FOUR_LEVELSIZE); if (self.quoContentHeight <= twoLine) { self.commentBack.userInteractionEnabled = NO; self.diandiandianLabel.hidden = YES; }else{ self.commentBack.userInteractionEnabled = YES; self.diandiandianLabel.hidden = NO; } if (!data.isQuoExpand || [data.isQuoExpand intValue] == 0) { self.quoContentHeight = self.quoContentHeight>twoLine?twoLine:self.quoContentHeight; }//TODO如果有图片havePic设为YES if (data.imageList.count > 0) { switch (data.imageList.count) { case 1: self.quoPic1.hidden = NO; self.quoPic2.hidden = YES; self.quoPic3.hidden = YES; break; case 2: self.quoPic1.hidden = NO; self.quoPic2.hidden = NO; self.quoPic3.hidden = YES; break; case 3: self.quoPic1.hidden = NO; self.quoPic2.hidden = NO; self.quoPic3.hidden = NO; break; default: break; } self.havePic = YES; [data.imageList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { imageObjectBO *image = obj; switch (idx) { case 0: self.quoPic1.imageUrl = image.url; self.quoPic1.imageId = getImageNameFromURL(image.url); break; case 1: self.quoPic2.imageUrl = image.url; self.quoPic2.imageId = getImageNameFromURL(image.url); break; case 2: self.quoPic3.imageUrl = image.url; self.quoPic3.imageId = getImageNameFromURL(image.url); break; default: break; } }]; } [self reLayoutSubViews]; } - (void)subLayoutSubViews { __weak typeof(self) weakSelf = self; [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.left).offset(10); make.right.equalTo(weakSelf.right).offset(-10); make.top.equalTo(weakSelf.top); make.bottom.equalTo(weakSelf.bottom); }]; [self.lineView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView.left).offset(10); make.right.equalTo(weakSelf.backView.right).offset(-10); make.bottom.equalTo(weakSelf.backView.bottom); make.height.mas_equalTo(1); }]; [self.quoNameLable makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.commentBack.left).offset(10); make.top.equalTo(weakSelf.commentBack.top).offset(10); make.width.mas_equalTo(weakSelf.commentBack).offset(-15); make.height.mas_equalTo(25/2); }]; [self.triangleImg makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.commentBack.left).offset(55/2); make.top.equalTo(self.commentBack.top).offset(-6); make.width.equalTo(@7); make.height.equalTo(@7); }]; } - (void)reLayoutSubViews { __weak typeof(self) weakSelf = self; CGFloat backHeight = 50/2+10; CGFloat labeHeight = 0; if (self.havePic) { backHeight += 15/2+quo_pic_width; } CGFloat diandianHeight = 0; // CGFloat twoLine = (appFont(TEXT_FOUR_LEVELSIZE, NO).lineHeight + 10)*2 - 10; if (!self.commentBO.isQuoExpand || [self.commentBO.isQuoExpand intValue] == 0) { labeHeight = (int)self.commentBO.labelHeight; if (labeHeight > getLineHeightWithCountAndFontWidth(2, 10, TEXT_FOUR_LEVELSIZE)) { labeHeight = getLineHeightWithCountAndFontWidth(2, 10, TEXT_FOUR_LEVELSIZE); backHeight += 15; diandianHeight = 15; } backHeight += labeHeight; }else { labeHeight = (int)self.commentBO.labelHeight; backHeight += labeHeight; } [self.commentBack remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView.left).offset(10); make.top.equalTo(weakSelf.backView.top).offset(10); make.right.equalTo(weakSelf.backView.right).offset(-10); make.height.mas_equalTo(backHeight); }]; [self.quoContentLabel remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.commentBack.left).offset(8); make.top.equalTo(self.quoNameLable.bottom).offset(5); make.right.equalTo(self.commentBack.right).offset(-8); make.height.mas_equalTo(labeHeight); }]; [self.diandiandianLabel remakeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.quoContentLabel.bottom); make.centerX.equalTo(self.backView); make.size.mas_equalTo(CGSizeMake(100, diandianHeight)); }]; [self.quoPic1 makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.commentBack.left).offset(10); make.top.equalTo(self.diandiandianLabel.bottom).offset(15/2); make.size.mas_equalTo(CGSizeMake(quo_pic_width, quo_pic_width)); }]; [self.quoPic2 makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.quoPic1.right).offset(10); make.top.equalTo(self.diandiandianLabel.bottom).offset(15/2); make.size.mas_equalTo(CGSizeMake(quo_pic_width, quo_pic_width)); }]; [self.quoPic3 makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.quoPic2.right).offset(10); make.top.equalTo(self.diandiandianLabel.bottom).offset(15/2); make.size.mas_equalTo(CGSizeMake(quo_pic_width, quo_pic_width)); }]; } @end