ForumCommentListViewModel.m 962 Bytes
Newer Older
Sandy's avatar
Sandy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//
//  ForumCommentListViewModel.m
//  Lighting
//
//  Created by Javen on 2017/4/18.
//  Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//

#import "ForumCommentListViewModel.h"
static UILabel *stringLabel = nil;
@implementation ForumCommentListViewModel

- (void)setReplyEntity:(CustomTOForumReplyEntity *)replyEntity {
    _replyEntity = replyEntity;
    self.height = 88;
    if (replyEntity.attachments.count > 0) {
        self.height = 88 + 164;
    }
    
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{ //生成一个用于计算文本高度的label
        stringLabel = [[UILabel alloc] init];
        stringLabel.font = [UIFont systemFontOfSize:17];
        stringLabel.numberOfLines = 0;
    });
    stringLabel.text = replyEntity.replyContent;
    self.height = self.height + [stringLabel sizeThatFits:CGSizeMake(ScreenWidth - 40, MAXFLOAT)].height + 16;
    NSLog(@"%f", self.height);
}
@end