// // MessageNoOpenCell.m // ThePaperBase // // Created by YoungLee on 15/12/16. // Copyright © 2015年 scar1900. All rights reserved. // #import "MessageNoOpenCell.h" @interface MessageNoOpenCell() @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UILabel *messageLabel; @property (nonatomic, strong) UILabel *pushClose; @property (nonatomic, strong) UIView *lineView; @property (nonatomic, strong) UILabel *msgLabel; @end @implementation MessageNoOpenCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self addSubview:self.backView]; UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, CGRectGetHeight(self.bounds))]; selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.selectedBackgroundView = selectView; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.backView addSubview:self.messageLabel]; [self.backView addSubview:self.pushClose]; [self.backView addSubview:self.lineView]; [self.backView addSubview:self.msgLabel]; [self subLayoutSubViews]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; } return self; } - (void)needrefreshNightMode:(id)sender{ UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, CGRectGetHeight(self.bounds))]; selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.selectedBackgroundView = selectView; self.backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; self.messageLabel.textColor = [UIColor colorWithHexString:TextGray]; } #pragma mark - getter - (UIView*)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } return _backView; } - (UIView *)lineView { if (!_lineView) { _lineView = [[UIView alloc] initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } -(UILabel *)pushClose{ if (!_pushClose) { _pushClose = [UILabel new]; _pushClose.textColor = [UIColor colorWithHexString:TextLightGray]; _pushClose.backgroundColor = [UIColor clearColor]; _pushClose.text = @"已关闭"; _pushClose.font = appFont(TEXT_FIVE_LEVELSIZE, NO); } return _pushClose; } - (UILabel *)messageLabel { if (!_messageLabel) { _messageLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _messageLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _messageLabel.textColor = [UIColor colorWithHexString:TextGray]; _messageLabel.backgroundColor = [UIColor clearColor]; _messageLabel.text = @"推送设置"; } return _messageLabel; } -(UILabel *)msgLabel{ if (!_msgLabel) { _msgLabel = [UILabel new]; _msgLabel.textColor = [UIColor colorWithHexString:TextLightGray]; _msgLabel.backgroundColor = [UIColor clearColor]; _msgLabel.text = @"您没有在系统中打开澎湃新闻客户端消息推送,请在系统“设置”-“通知中心”中,找到应用程序“澎湃新闻”打开新消息通知"; _msgLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO); _msgLabel.numberOfLines = 0; _msgLabel.lineBreakMode = NSLineBreakByWordWrapping; } return _msgLabel; } #pragma mark - layout - (void)subLayoutSubViews { [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(10); make.right.equalTo(self).offset(-10); make.top.equalTo(self); make.height.mas_equalTo(50); }]; [self.messageLabel makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.backView); make.left.equalTo(self.backView).offset(10); make.size.mas_equalTo(CGSizeMake(150, 20)); }]; [self.pushClose makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.right).offset(-55); make.width.mas_equalTo(55); make.top.equalTo(self.backView); make.bottom.equalTo(self.backView); }]; [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); }]; [self.msgLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView); make.right.equalTo(self.backView); make.top.equalTo(self.backView.bottom).offset(5); make.height.mas_equalTo(45); }]; } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)dealloc { [[NSNotificationCenter defaultCenter]removeObserver:self]; } @end