热更新demo

CleanTableViewCell.m 5.4KB

    // // CleanTableViewCell.m // ThePaperBase // // Created by zhousan on 15/8/14. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "CleanTableViewCell.h" @interface CleanTableViewCell () @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UILabel *cleanLabel; @property (nonatomic, strong) UILabel *fileLabel; @property (nonatomic, strong) UIButton *cleanBtn; @property (nonatomic, strong) UIView *lineView; @end @implementation CleanTableViewCell - (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.cleanLabel]; [self.backView addSubview:self.fileLabel]; [self.backView addSubview:self.cleanBtn]; [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.fileLabel.textColor = [UIColor colorWithHexString:TextLightGray]; self.fileLabel.textColor = [UIColor colorWithHexString:TextLightGray]; self.cleanLabel.textColor = [UIColor colorWithHexString:TextGray]; } - (void)setFileString:(NSString *)fileString { _fileString = fileString; self.fileLabel.text = _fileString; } - (UILabel *)cleanLabel { if (!_cleanLabel) { _cleanLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _cleanLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _cleanLabel.textColor = [UIColor colorWithHexString:TextGray]; _cleanLabel.backgroundColor = [UIColor clearColor]; _cleanLabel.text = @"清理缓存"; } return _cleanLabel; } - (UILabel *)fileLabel { if (!_fileLabel) { _fileLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _fileLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO); _fileLabel.textColor = [UIColor colorWithHexString:TextLightGray]; _fileLabel.backgroundColor = [UIColor clearColor]; } return _fileLabel; } - (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; } - (UIButton *)cleanBtn { if (!_cleanBtn) { _cleanBtn = [[UIButton alloc] initWithFrame:CGRectZero]; [_cleanBtn setImage:Image(@"setting/delete.png") forState:UIControlStateNormal]; [_cleanBtn setImage:Image(@"setting/delete.png") forState:UIControlStateHighlighted]; _cleanBtn.userInteractionEnabled = NO; // [_cleanBtn addTarget:self action:@selector(cleanBtnClick:) forControlEvents:UIControlEventTouchUpInside]; } return _cleanBtn; } //- (void)cleanBtnClick:(UIButton *)btn { // if ([self.delegate respondsToSelector:@selector(cleanBtnClick:)]) { // [self.delegate cleanBtnClick: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.cleanLabel makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.backView.top).offset(8); make.left.equalTo(self.backView).offset(10); make.size.mas_equalTo(CGSizeMake(150, 16)); }]; [self.fileLabel makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.cleanLabel.bottom).offset(5); make.left.equalTo(self.backView).offset(10); make.size.mas_equalTo(CGSizeMake(150, 12)); }]; [self.cleanBtn makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.backView).offset(-10); make.centerY.equalTo(self.backView); make.size.mas_equalTo(CGSizeMake(30, 30)); }]; [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 } - (void)dealloc { [[NSNotificationCenter defaultCenter]removeObserver:self]; } @end