// // messageQuoCell.m // ThePaperBase // // Created by YoungLee on 15/12/15. // Copyright © 2015年 scar1900. All rights reserved. // #import "messageQuoCell.h" @implementation messageQuoCell @synthesize commentBO = _commentBO; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleNone; } return self; } - (void)dealloc { self.backView = nil; self.commentBack = nil; self.quoContentLabel = nil; self.quoNameLable = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)setCommentBO:(commentObjectVO *)data { _commentBO = data; self.quoNameLable.text = @"我:"; self.quoContentLabel.attributedText = getLineSpaceAttributedString(data.content, 10, appFont(interactionFontSize, NO)); self.quoContentHeight = data.labelHeight; CGFloat twoLine = twoLineheight; 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 [self reLayoutSubViews]; } - (void)subLayoutSubViews { __weak typeof(self) weakSelf = self; [self.backView makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }]; [self.lineView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView.left).offset(15); make.right.equalTo(weakSelf.backView.right).offset(-15); 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; CGFloat diandianHeight = 0; // CGFloat twoLine = (appFont(TEXT_FOUR_LEVELSIZE, NO).lineHeight + 10)*2 - 10; if (!self.commentBO.isQuoExpand || [self.commentBO.isQuoExpand intValue] == 0) { labeHeight = self.commentBO.labelHeight; if (labeHeight > twoLineheight) { labeHeight = twoLineheight; backHeight += 15; diandianHeight = 15; } backHeight += labeHeight; }else { labeHeight = self.commentBO.labelHeight; backHeight += labeHeight; } [self.commentBack remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView.left).offset(15); make.top.equalTo(weakSelf.backView.top).offset(10); make.right.equalTo(weakSelf.backView.right).offset(-15); 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)); }]; } - (void)awakeFromNib { // Initialization code rampage } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end