热更新demo

channelPromoteTitleCell.m 3.9KB

    // // channelPromoteTitleCell.m // ThePaperBase // // Created by scar1900 on 15/7/30. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "channelPromoteTitleCell.h" @interface channelPromoteTitleCell() @property(nonatomic, strong)UIView *backView; @property(nonatomic, strong)UILabel *titleLabel; @property(nonatomic, strong)UIView *lineView; @property(nonatomic, strong)UIView *colorView; @end @implementation channelPromoteTitleCell @synthesize titleText = _titleText; - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.backView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.lineView]; [self.contentView addSubview:self.colorView]; [self.backView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).offset(10); make.right.equalTo(self.contentView.right).offset(-10); make.top.equalTo(self.contentView.top).offset(10); make.bottom.equalTo(self.contentView.bottom); }]; [self.titleLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left).offset(10); make.right.equalTo(self.backView.right); make.top.equalTo(self.backView.top); make.bottom.equalTo(self.backView.bottom); }]; [self.lineView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left); make.right.equalTo(self.backView.right); make.bottom.equalTo(self.contentView.bottom); make.height.equalTo(@0.5); }]; [self.colorView makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.backView.left); make.centerY.equalTo(self.backView.centerY); make.width.equalTo(@1); make.height.equalTo(@16); }]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; } return self; } - (UIView*)backView { if (!_backView) { _backView = [UIView new]; _backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } return _backView; } - (UIView*)colorView { if (!_colorView) { _colorView = [UIView new];//e3781e _colorView.backgroundColor = [UIColor colorWithHexString:@"0xe3781e"]; } return _colorView; } - (UIView*)lineView { if (!_lineView) { _lineView = [UIView new]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (UILabel*)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; _titleLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; _titleLabel.textAlignment = NSTextAlignmentLeft; } _titleLabel.font = appFont(TEXT_FIVE_LEVELSIZE, NO); return _titleLabel; } - (void)setTitleText:(NSString *)text { _titleText = text; self.titleLabel.text = text; self.titleLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO); } - (void)layoutSubviews { [super layoutSubviews]; } - (void)needrefreshNightMode:(id)sender{ self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.titleLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } @end