// // MarkTableViewCell.m // ThePaperBase // // Created by Huixin on 15/12/23. // Copyright © 2015年 scar1900. All rights reserved. // #import "MarkTableViewCell.h" @interface MarkTableViewCell () @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UILabel *markLabel; @property (nonatomic, strong) UIButton *markBtn; @property (nonatomic, strong) UIView *lineView; @end @implementation MarkTableViewCell - (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.backView addSubview:self.markLabel]; [self.backView addSubview:self.markBtn]; [self.backView addSubview:self.lineView]; [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.markLabel.textColor = [UIColor colorWithHexString:TextGray]; } - (UIView *)lineView { if (!_lineView) { _lineView = [[UIView alloc] initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (UILabel *)markLabel { if (!_markLabel) { _markLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _markLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _markLabel.textColor = [UIColor colorWithHexString:TextGray]; _markLabel.backgroundColor = [UIColor clearColor]; _markLabel.text = @"去评分"; } return _markLabel; } - (UIView*)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } return _backView; } - (UIButton *)markBtn { if (!_markBtn) { _markBtn = [[UIButton alloc] initWithFrame:CGRectZero]; [_markBtn setImage:Image(@"setting/message_notificationcell_arrow.png") forState:UIControlStateNormal]; [_markBtn setImage:Image(@"setting/message_notificationcell_arrow.png") forState:UIControlStateHighlighted]; _markBtn.userInteractionEnabled = NO; } return _markBtn; } #pragma mark - layout - (void)subLayoutSubViews { __weak typeof(self) weakSelf = self; [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf).offset(10); make.right.equalTo(weakSelf).offset(-10); make.top.equalTo(weakSelf); make.bottom.equalTo(weakSelf); }]; [self.markLabel makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(weakSelf.backView); make.left.equalTo(weakSelf.backView).offset(10); make.size.mas_equalTo(CGSizeMake(150, 20)); }]; [self.markBtn makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(weakSelf.backView).offset(-10); make.centerY.equalTo(weakSelf.backView); make.size.mas_equalTo(CGSizeMake(9, 16)); }]; [self.lineView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(weakSelf.backView); make.right.equalTo(weakSelf.backView); make.bottom.equalTo(weakSelf.backView); make.height.mas_equalTo(1); }]; } - (void)dealloc { [[NSNotificationCenter defaultCenter]removeObserver:self]; } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end