澎湃iPad上线版本

letterInfoTopicCell.m 5.0KB

    // // letterInfoTopicCell.m // ThePaperHD // // Created by liyuan on 15/7/17. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "letterInfoTopicCell.h" @interface letterInfoTopicCell() @property(nonatomic, strong)UILabel *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 -(UILabel *)topicLabel{ if (!_topicLabel) { _topicLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _topicLabel.font = appFont(17, NO); _topicLabel.textColor = [UIColor colorWithHexString:TextBlack]; _topicLabel.lineBreakMode = NSLineBreakByWordWrapping; _topicLabel.numberOfLines = 0; _topicLabel.backgroundColor = [UIColor clearColor]; } return _topicLabel; } -(UILabel *)nameLabel{ if (!_nameLabel) { _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _nameLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; _nameLabel.font = appFont(12, NO); _nameLabel.backgroundColor = [UIColor clearColor]; } return _nameLabel; } -(UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _timeLabel.font = appFont(12, 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; [self layoutSubviews]; } -(void)layoutSubviews{ [super layoutSubviews]; CGSize titleSize = [self.topicLabel sizeThatFits:CGSizeMake(CGRectGetWidth(self.contentView.bounds)-30, 0)]; CGFloat titleHeight = titleSize.height; self.topicLabel.frame = CGRectMake(15, 25, CGRectGetWidth(self.contentView.bounds)-30, titleHeight); self.nameLabel.frame = CGRectMake(CGRectGetMinX(self.topicLabel.frame), CGRectGetMaxY(self.topicLabel.frame)+15,widthForString(self.nameLabel.text, self.nameLabel.font, 20, NSLineBreakByWordWrapping), 20); self.timeLabel.frame = CGRectMake(CGRectGetMaxX(self.nameLabel.frame)+5, CGRectGetMaxY(self.topicLabel.frame)+15, widthForString(self.timeLabel.text, self.timeLabel.font, 20, NSLineBreakByWordWrapping), 20); self.line.frame = CGRectMake(15, CGRectGetHeight(self.contentView.bounds)-1, CGRectGetWidth(self.contentView.bounds)-30, 1); // [self.topicLabel makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.contentView.left).offset(15); // make.right.equalTo(self.contentView.right).offset(-15); // make.top.equalTo(self.contentView.top).offset(25); // make.height.mas_equalTo(titleHeight); // }]; // [self.nameLabel makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.topicLabel.left); // make.width.equalTo(widthForString(self.nameLabel.text, self.nameLabel.font, 20, NSLineBreakByWordWrapping)); // make.top.equalTo(self.topicLabel.bottom).offset(25); // make.height.mas_equalTo(20); // }]; // [self.timeLabel makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.nameLabel.right).offset(5); // make.width.equalTo(widthForString(self.timeLabel.text, self.timeLabel.font, 20, NSLineBreakByWordWrapping)); // make.top.equalTo(self.nameLabel.top); // make.height.mas_equalTo(20); // }]; // [self.line makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(self.topicLabel.left); // make.right.equalTo(self.topicLabel.right); // make.top.equalTo(self.nameLabel.bottom).offset(10); // make.height.equalTo(1); // }]; } @end