热更新demo

ReadKindTableViewCell.m 4.6KB

    // // ReadKindTableViewCell.m // ThePaperBase // // Created by zhousan on 15/8/14. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "ReadKindTableViewCell.h" @interface ReadKindTableViewCell () @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UILabel *readLabel; @property (nonatomic, strong) UIButton *readBtn; @property (nonatomic, strong) UIView *lineView; @end @implementation ReadKindTableViewCell - (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.readLabel]; [self.backView addSubview:self.readBtn]; [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.readLabel.textColor = [UIColor colorWithHexString:TextGray]; } - (void)awakeFromNib { // Initialization code } - (UILabel *)readLabel { if (!_readLabel) { _readLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _readLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _readLabel.textColor = [UIColor colorWithHexString:TextGray]; _readLabel.backgroundColor = [UIColor clearColor]; _readLabel.text = @"阅读模式"; } return _readLabel; } - (UIView*)backView { if (!_backView) { _backView = [[UIView alloc]initWithFrame:CGRectZero]; _backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } return _backView; } - (UIButton *)readBtn { if (!_readBtn) { _readBtn = [[UIButton alloc] initWithFrame:CGRectZero]; [_readBtn setImage:Image(@"setting/message_notificationcell_arrow.png") forState:UIControlStateNormal]; [_readBtn setImage:Image(@"setting/message_notificationcell_arrow.png") forState:UIControlStateHighlighted]; _readBtn.userInteractionEnabled = NO; // [_readBtn addTarget:self action:@selector(readBtnClick:) forControlEvents:UIControlEventTouchUpInside]; } return _readBtn; } //- (void)readBtnClick:(UIButton *)btn { // if ([self.delegate respondsToSelector:@selector(readBtnClick:)]) { // [self.delegate readBtnClick:btn]; // } //} #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.bottom.equalTo(self); }]; [self.readLabel makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.backView); make.left.equalTo(self.backView).offset(10); make.size.mas_equalTo(CGSizeMake(150, 20)); }]; [self.readBtn makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.backView).offset(-10); make.centerY.equalTo(self.backView); make.size.mas_equalTo(CGSizeMake(9, 16)); }]; [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); }]; } - (UIView *)lineView { if (!_lineView) { _lineView = [[UIView alloc] initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (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