// // letterInfoTopicCell.m // ThePaperHD // // Created by liyuan on 15/7/17. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "letterInfoTopicCell.h" @interface letterInfoTopicCell(){ CGFloat titleHeight; } @property(nonatomic, strong)UIView *backView; @property(nonatomic, strong)RTLabel *topicLabel; @property(nonatomic, strong)UILabel *nameLabel; @property(nonatomic, strong)UILabel *timeLabel; @property(nonatomic, strong)UILabel *line; @end @implementation letterInfoTopicCell @synthesize letterBo = _letterBo; - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; // self.backgroundColor = [UIColor redColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.topicLabel]; [self.contentView addSubview:self.nameLabel]; [self.contentView addSubview:self.timeLabel]; // [self.contentView addSubview:self.line]; } return self; } #pragma mark -- view -(RTLabel *)topicLabel{ if (!_topicLabel) { _topicLabel = [[RTLabel alloc]initWithFrame:CGRectZero]; _topicLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _topicLabel.textColor = [UIColor colorWithHexString:TextBlack]; // _topicLabel.lineBreakMode = NSLineBreakByWordWrapping; // _topicLabel.numberOfLines = 0; _topicLabel.lineSpacing = 7; _topicLabel.lineBreakMode = RTTextLineBreakModeWordWrapping; _topicLabel.backgroundColor = [UIColor clearColor]; } return _topicLabel; } -(UILabel *)nameLabel{ if (!_nameLabel) { _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _nameLabel.textColor = [UIColor colorWithHexString:TextLightGray]; _nameLabel.font = appFont(TEXT_SEVEN_LEVELSIZE, NO); _nameLabel.backgroundColor = [UIColor clearColor]; } return _nameLabel; } -(UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _timeLabel.font = appFont(TEXT_SEVEN_LEVELSIZE, NO); _timeLabel.textColor = [UIColor colorWithHexString:TextLightGray]; _timeLabel.backgroundColor = [UIColor clearColor]; } return _timeLabel; } -(UILabel *)line{ if (!_line) { _line = [[UILabel alloc]initWithFrame:CGRectZero]; _line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _line; } #pragma mark -- set Date -(void)setLetterBo:(letterBO *)bo{ _letterBo = bo; self.topicLabel.text = _letterBo.title; userBO *user = setJsonDicToDataModel(_letterBo.userInfo, [userBO class]); if(isBlankString(user.sname)){ self.nameLabel.text = @""; }else{ self.nameLabel.text = user.sname; } self.timeLabel.text = _letterBo.pubTime; titleHeight = returnTextHeightWithRTLabel(self.topicLabel.text, rect_screen.size.width -20, self.topicLabel.font, 7); [self setLayout]; } -(void)setLayout{ // CGSize titleSize = [self.topicLabel sizeThatFits:CGSizeMake(rect_screen.size.width-20, 0)]; // CGFloat titleHeight = titleSize.height; [self.topicLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(@10); make.right.equalTo(self.contentView.right).offset(-10); make.top.equalTo(self.contentView.top).offset(15); make.height.equalTo(titleHeight); }]; [self.nameLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.topicLabel.left); make.right.equalTo(self.contentView.right).offset(-10); make.top.equalTo(self.topicLabel.bottom).offset(8); make.height.equalTo(@10); }]; [self.timeLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.topicLabel.left); make.right.equalTo(self.contentView.right).offset(-10); make.top.equalTo(self.nameLabel.bottom).offset(5); make.height.equalTo(@10); }]; } @end