热更新demo

letterInfoContentCell.m 2.8KB

    // // letterInfoContentCell.m // ThePaperHD // // Created by liyuan on 15/7/17. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "letterInfoContentCell.h" @interface letterInfoContentCell(){ CGFloat contentHieght; } @property(nonatomic, strong)UITextView *content; @end @implementation letterInfoContentCell @synthesize contentStr = _contentStr; - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; // self.backgroundColor = [UIColor purpleColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.content]; } return self; } -(UITextView *)content{ if (!_content) { _content = [[UITextView alloc]initWithFrame:CGRectZero]; _content.font = appFont(TEXT_FOUR_LEVELSIZE, NO); _content.textColor = [UIColor colorWithHexString:TextBlack]; [_content setEditable:NO]; _content.scrollEnabled = NO; _content.showsVerticalScrollIndicator = NO; _content.showsHorizontalScrollIndicator = NO; // _content.lineBreakMode = NSLineBreakByWordWrapping; // _content.numberOfLines = 0; // _content.lineSpacing = 7; // _content.lineBreakMode = RTTextLineBreakModeWordWrapping; _content.backgroundColor = [UIColor clearColor]; } return _content; } -(void)setContentStr:(NSString *)str{ _contentStr = str; // self.content.text = _contentStr; self.content.attributedText = getLineSpaceAttributedString(_contentStr, 7, appFont(TEXT_FOUR_LEVELSIZE, NO)); // CGSize contentSize = [self.content sizeThatFits:CGSizeMake(rect_screen.size.width - 20, 0)]; // contentHieght = contentSize.height; // contentHieght = returnTextHeightWithRTLabel(self.content.text, rect_screen.size.width - 20, self.content.font, 7); contentHieght = heightForAttributeString(getLineSpaceAttributedString(_contentStr, 7, appFont(TEXT_FOUR_LEVELSIZE, NO)), rect_screen.size.width - 20, appFont(TEXT_FOUR_LEVELSIZE, NO)); self.content.textColor = [UIColor colorWithHexString:TextBlack]; [self setLayout]; } -(void)setLayout{ [self.content 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.height.mas_equalTo(contentHieght); }]; } @end