热更新demo

titleAndAuthorCell.m 2.4KB

    // // titleAndAuthorCell.m // ThePaperDemo // // Created by Scar on 14-9-18. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "titleAndAuthorCell.h" @interface titleAndAuthorCell() { CGFloat contentPadding; } @property(nonatomic, strong)UITextView *titleLabel; @end @implementation titleAndAuthorCell @synthesize contentTitle = _contentTitle; @synthesize titleLabelHeight; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { if (IS_IPHONE_6P) { contentPadding = 15; }else if (IS_IPHONE_6) { contentPadding = 15; }else { contentPadding = 10; } // Initialization code self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.titleLabel]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; } return self; } - (void)needrefreshNightMode:(id)sender{ self.titleLabel.backgroundColor = [UIColor clearColor]; self.titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; [self.titleLabel setNeedsDisplay]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (UITextView*)titleLabel { if (!_titleLabel) { _titleLabel = [[UITextView alloc]initWithFrame:CGRectZero]; _titleLabel.backgroundColor = [UIColor clearColor]; _titleLabel.textAlignment = NSTextAlignmentLeft; _titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; [_titleLabel setEditable:NO]; _titleLabel.scrollEnabled = NO; _titleLabel.showsHorizontalScrollIndicator = NO; _titleLabel.showsVerticalScrollIndicator = NO; } return _titleLabel; } - (void)setContentTitle:(NSAttributedString *)title { _contentTitle = title; self.titleLabel.attributedText = title; self.titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; } #pragma mark - layout method - (void)layoutSubviews { [super layoutSubviews]; self.titleLabel.frame = CGRectMake(contentPadding, 45/2, CGRectGetWidth(self.bounds)-2*contentPadding, self.titleLabelHeight); } - (void)awakeFromNib { // Initialization code } @end