澎湃iPad上线版本

pushMsgCell.m 3.6KB

    // // pushMsgCell.m // ThePaperHD // // Created by liyuan on 15/7/20. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "pushMsgCell.h" @interface pushMsgCell(){ CGFloat titleHeight; } @property(nonatomic, strong) RTLabel *titleLabel; @property(nonatomic, strong) UIImageView *timeIcon; @property(nonatomic, strong) UILabel *timeLabel; @property(nonatomic, strong) UIView *line; @end @implementation pushMsgCell @synthesize data = _data; - (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.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.timeIcon]; [self.contentView addSubview:self.timeLabel]; [self.contentView addSubview:self.line]; } return self; } #pragma mark -- data -(void)setData:(letterBO *)bo{ _data = bo; // titleHeight = heightForString(_data.title, appFont(17, NO), messagePopSize.width-30, NSLineBreakByWordWrapping); self.titleLabel.text = _data.summary; self.timeLabel.text = _data.pubTime; [self layoutSubviews]; } #pragma mark -- view -(RTLabel *)titleLabel{ if (!_titleLabel) { _titleLabel = [[RTLabel alloc] initWithFrame:CGRectZero]; _titleLabel.font = appFont(TEXT_TWO_LEVELSIZE, NO); _titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; // _titleLabel.numberOfLines = 0; // _titleLabel.lineBreakMode = NSLineBreakByWordWrapping; _titleLabel.lineBreakMode = RTTextLineBreakModeWordWrapping; _titleLabel.lineSpacing = 8; _titleLabel.backgroundColor = [UIColor clearColor]; } return _titleLabel; } -(UIImageView *)timeIcon{ if (!_timeIcon) { _timeIcon = [[UIImageView alloc] initWithFrame:CGRectZero]; _timeIcon.image = Image(@"setting/showTime.png"); } return _timeIcon; } -(UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _timeLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO); _timeLabel.textColor = [UIColor colorWithHexString:TextGray]; _timeLabel.lineBreakMode = NSLineBreakByWordWrapping; _timeLabel.backgroundColor = [UIColor clearColor]; } return _timeLabel; } -(UIView *)line{ if (!_line) { _line = [[UIView alloc]initWithFrame:CGRectZero]; _line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _line; } -(void)layoutSubviews{ [super layoutSubviews]; titleHeight = returnTextHeightWithRTLabel(self.titleLabel.text, messagePopSize.width-30, self.titleLabel.font, 8); self.titleLabel.frame = CGRectMake(15, 30, CGRectGetWidth(self.contentView.bounds)-30, titleHeight); self.timeIcon.frame = CGRectMake(CGRectGetMinX(self.titleLabel.frame), CGRectGetMaxY(self.titleLabel.frame)+10, 10, 10); self.timeLabel.frame = CGRectMake(CGRectGetMaxX(self.timeIcon.frame)+5, CGRectGetMinY(self.timeIcon.frame),CGRectGetWidth(self.contentView.bounds)-40-CGRectGetMaxX(self.timeIcon.frame), 10); self.line.frame = CGRectMake(15, CGRectGetHeight(self.contentView.bounds)-2, CGRectGetWidth(self.contentView.bounds)-30, 1); } @end