// // NewsForHotAnswerCell.m // ThePaperBase // // Created by zhousan on 15/8/27. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "NewsForHotAnswerCell.h" @interface NewsForHotAnswerCell () @property (nonatomic, strong) UILabel *newsLabel; @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UIView *lineView; @end @implementation NewsForHotAnswerCell - (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]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)setComment:(commentObjectVO *)comment { _comment = comment; NSString *str = @""; if ([_comment.objectType isEqualToString:@"3"]) { str = @"【原话题】"; }else if ([_comment.objectType isEqualToString:@"1"]) { str = @"【原新闻】"; } self.newsLabel.text = [NSString stringWithFormat:@"%@%@",str,comment.contName]; } - (UILabel *)newsLabel { if (nil == _newsLabel) { _newsLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, rect_screen.size.width-40, 0)]; _newsLabel.textColor = [UIColor colorWithHexString:TextGray]; _newsLabel.font = appFont(11, NO); _newsLabel.lineBreakMode = NSLineBreakByCharWrapping; _newsLabel.numberOfLines = 0; } return _newsLabel; } - (UIView *)lineView { if (nil == _lineView) { _lineView = [[UIView alloc] initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } 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(5); make.right.equalTo(self.backView.right).offset(-10); make.bottom.mas_equalTo(self.backView.bottom).offset(-5); }]; [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