// // relateNewsCell.m // ThePaperHD // // Created by scar1900 on 15/5/13. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "relateNewsCell.h" #define tableWidht 1230/2 @interface relateNewsCell() { CGFloat contentHeight; } @property(nonatomic, strong)UIView* backView; @property(nonatomic, strong)UILabel* contentLabel; @property(nonatomic, strong)UILabel *timeLabel; @property(nonatomic, strong)UIView *lineView; @property(nonatomic, strong)UIView *selectView; @end @implementation relateNewsCell @synthesize padding; @synthesize listBO = _listBO; - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleGray; self.selectedBackgroundView = self.selectView; self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.contentView addSubview:self.backView]; [self.backView addSubview:self.contentLabel]; [self.backView addSubview:self.timeLabel]; [self.backView addSubview:self.lineView]; } return self; } - (UIView *)selectView { if (!_selectView) { _selectView = [[UIView alloc]initWithFrame:CGRectZero]; _selectView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _selectView; } - (void)setListBO:(listContObjectVO *)data { _listBO = data; contentHeight = heightForString(data.name, appFont(18, NO), tableWidht, NSLineBreakByWordWrapping); self.contentLabel.text = data.name; self.timeLabel.text = data.pubTime; [self layoutSubviews]; } - (UIView *)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.backgroundColor = [UIColor clearColor]; } return _backView; } - (UILabel*)contentLabel { if (!_contentLabel) { _contentLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _contentLabel.font = appFont(18, NO); _contentLabel.textColor = [UIColor colorWithHexString:TextBlack]; _contentLabel.textAlignment = NSTextAlignmentLeft; _contentLabel.lineBreakMode = NSLineBreakByWordWrapping; _contentLabel.numberOfLines = 0; _contentLabel.backgroundColor = [UIColor clearColor]; } return _contentLabel; } - (UILabel*)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _timeLabel.textColor = [UIColor colorWithHexString:LIGHTGRAY]; _timeLabel.font = appFont(11, NO); _timeLabel.textAlignment = NSTextAlignmentLeft; _timeLabel.backgroundColor = [UIColor clearColor]; } return _timeLabel; } - (UIView*)lineView { if (!_lineView) { _lineView = [[UIView alloc]initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (void)layoutSubviews { [super layoutSubviews]; self.backView.frame = CGRectMake(padding, 0, tableWidht, CGRectGetHeight(self.contentView.bounds)); self.selectView.frame = self.backView.frame; self.contentLabel.frame = CGRectMake(0, 15, tableWidht, contentHeight); self.timeLabel.frame = CGRectMake(0, CGRectGetMaxY(self.contentLabel.frame)+15, tableWidht, 13); self.lineView.frame = CGRectMake(0, CGRectGetHeight(self.backView.bounds)-1, tableWidht, 1); } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end