// // msgAnswerIconBaseCell.m // ThePaperBase // // Created by YoungLee on 15/11/18. // Copyright © 2015年 scar1900. All rights reserved. // #import "msgAnswerIconCell.h" @interface msgAnswerIconCell(){ CGFloat answerWidth; } @end @implementation msgAnswerIconCell @synthesize commentBO = _commentBO; -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.selectionStyle = UITableViewCellSelectionStyleNone; self.anserNameLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; [self.backView removeFromSuperview]; [self.contentView addSubview:self.backView]; [self.backView addSubview:self.dotImg]; [self.backView addSubview:self.fastComment]; self.OkButton.hidden = YES; self.verifyTag.hidden = YES; self.iconBack.hidden = YES; self.iconButton.hidden = YES; self.timeImg.hidden = YES; self.timeLabel.hidden = YES; self.hostLabel.hidden = YES; self.attentionBtn.hidden = YES; self.topicNumsLabel.hidden = YES; self.replyButton.hidden = YES; self.backBtn.hidden = YES; } return self; } -(UIButton *)fastComment{ if (!_fastComment) { _fastComment = [UIButton buttonWithType:UIButtonTypeCustom]; _fastComment.backgroundColor = [UIColor clearColor]; [_fastComment setTitle:@"回复" forState:UIControlStateNormal]; [_fastComment setTitleColor:[UIColor colorWithHexString:TextBlack] forState:UIControlStateNormal]; _fastComment.hidden = YES; _fastComment.titleLabel.font =appFont(TEXT_SIX_LEVELSIZE, NO); _fastComment.titleEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 10); [_fastComment addTarget:self action:@selector(fastCommentSelector:) forControlEvents:UIControlEventTouchUpInside]; } return _fastComment; } -(void)setCommentBO:(commentObjectVO *)comment{ _commentBO = comment; // if (_commentBO.parentInfo) { // self.dotImg.hidden = NO; // }else{ // self.dotImg.hidden = YES; // } userBO *user = setJsonDicToDataModel(_commentBO.userInfo, [userBO class]); if ([[TPUserDefault instance].userBO.userId intValue] == [user.userId intValue]) { self.anserNameLabel.text = @"我:"; }else{ self.anserNameLabel.text = [NSString stringWithFormat:@"%@:",user.sname]; } answerWidth = 10 + widthForString(self.anserNameLabel.text, self.anserNameLabel.font, 20, self.anserNameLabel.lineBreakMode); [self setLayout]; } -(UIImageView *)dotImg{ if (!_dotImg) { _dotImg = [UIImageView new]; _dotImg.image = Image(@"topic/dottedLine.png"); _dotImg.hidden = YES; } return _dotImg; } -(void)fastCommentSelector:(UIButton*) btn{ if ([self.delegate respondsToSelector:@selector(gotoCommentWithComment:)]) { [self.delegate gotoCommentWithComment:self.commentBO]; } } -(void)setLayout{ [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.left).offset(10); make.right.equalTo(self.right).offset(-10); make.top.equalTo(self.top); make.bottom.equalTo(self.bottom); }]; [self.dotImg makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left); make.right.equalTo(self.backView.right); make.top.equalTo(self.backView.top); make.height.mas_equalTo(1); }]; [self.anserNameLabel remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left).offset(10); make.width.equalTo(answerWidth); make.top.equalTo(self.backView.top).offset(10); make.bottom.equalTo(self.backView.bottom); }]; [self.nameButton makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.anserNameLabel.left); make.right.equalTo(self.anserNameLabel.right); make.top.equalTo(self.anserNameLabel.top); make.bottom.equalTo(self.anserNameLabel.bottom); }]; [self.fastComment makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.backView.right); make.width.mas_equalTo(35); make.top.equalTo(self.backView.top); make.bottom.equalTo(self.backView.bottom); }]; } @end