// // NewsForHotCommentCell.m // ThePaperBase // // Created by zhousan on 15/8/26. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "NewsForHotCommentCell.h" @interface NewsForHotCommentCell () @property (nonatomic, strong) RTLabel *newsLabel; @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UIImageView *lineView; @end @implementation NewsForHotCommentCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.backgroundColor = [UIColor clearColor]; [self.contentView addSubview:self.backView]; [self.backView addSubview:self.newsLabel]; [self.backView addSubview:self.lineView]; [self subLayoutSubViews]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; } return self; } - (void)needrefreshNightMode:(id)sender{ self.backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; _newsLabel.textColor = [UIColor colorWithHexString:TextGray]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)setComment:(commentObjectVO *)comment { _comment = comment; self.newsLabel.text = [NSString stringWithFormat:@"【原新闻】%@",comment.contName]; } - (RTLabel *)newsLabel { if (nil == _newsLabel) { _newsLabel = [[RTLabel alloc] initWithFrame:CGRectMake(0, 0, rect_screen.size.width-40, 0)]; _newsLabel.textColor = [UIColor colorWithHexString:TextGray]; _newsLabel.textAlignment = RTTextAlignmentLeft; _newsLabel.lineBreakMode = RTTextLineBreakModeWordWrapping; _newsLabel.lineSpacing = 7; _newsLabel.font = appFont(TEXT_FOUR_LEVELSIZE, NO); } return _newsLabel; } - (UIImageView *)lineView { if (nil == _lineView) { _lineView = [[UIImageView alloc] initWithFrame:CGRectZero]; _lineView.image = Image(@"topic/dottedLine.png"); } return _lineView; } - (UIView*)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } return _backView; } - (void)awakeFromNib { // Initialization code } - (void)subLayoutSubViews { [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).offset(10); make.top.equalTo(self.contentView.top).offset(10); make.right.equalTo(self.contentView.right).offset(-10); make.bottom.equalTo(self.contentView.bottom); }]; [self.newsLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left).offset(10); make.top.equalTo(self.backView.top).offset(10); make.right.equalTo(self.backView.right).offset(-10); make.bottom.mas_equalTo(self.backView.bottom).offset(-10); }]; [self.lineView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView); make.right.equalTo(self.backView); make.bottom.equalTo(self.backView); make.height.mas_equalTo(1); }]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end