热更新demo

authorAndTimeCell.m 2.3KB

    // // authorAndTimeCell.m // ThePaperDemo // // Created by Scar on 14-9-18. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "authorAndTimeCell.h" @interface authorAndTimeCell() { CGFloat contentPadding; CGFloat authorHeight; } @property(nonatomic, strong)UILabel *cellTextLabel; @end @implementation authorAndTimeCell @synthesize text = _text; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code if (IS_IPHONE_6P) { contentPadding = 15; }else if (IS_IPHONE_6) { contentPadding = 15; }else { contentPadding = 10; } self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self addSubview:self.cellTextLabel]; } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil]; return self; } - (void)needrefreshNightMode:(id)sender{ _cellTextLabel.textColor = [UIColor colorWithHexString:TextGray]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)setText:(NSAttributedString *)str { _text = str; self.cellTextLabel.attributedText =str; authorHeight = heightForAttributeStringWithLabel(str, rect_screen.size.width-2*contentPadding, appFont([iphoneLineSpaceAndParaSpace returnLevel1plus5FontSize], NO)); [self layoutSubviews]; } - (UILabel*)cellTextLabel { if (!_cellTextLabel) { _cellTextLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _cellTextLabel.backgroundColor = [UIColor clearColor]; _cellTextLabel.textAlignment = NSTextAlignmentLeft; _cellTextLabel.textColor = [UIColor colorWithHexString:TextGray]; _cellTextLabel.lineBreakMode = NSLineBreakByWordWrapping; _cellTextLabel.numberOfLines = 0; } return _cellTextLabel; } - (void)layoutSubviews { [super layoutSubviews]; self.cellTextLabel.frame = CGRectMake(contentPadding, 0, CGRectGetWidth(self.bounds)-2*contentPadding, authorHeight); } - (void)awakeFromNib { // Initialization code } @end