chatMsgModel.m 1.52 KB
//
//  chatMsgModel.m
//  LiveVideoCloud
//
//  Created by 张旭 on 2017/3/20.
//  Copyright © 2017年 cnlive. All rights reserved.
//

#import "chatMsgModel.h"

#define ChatCellMargin 10

@implementation chatMsgModel

- (CGFloat)cellHeight
{
    //如果计算过高度,直接返回
    if (_cellHeight) return _cellHeight;
    
    _cellHeight = 0;
    NSString *content = [NSString stringWithFormat:@"%@:%@",self.name,self.content];
    //文字
    CGFloat textMaxW = self.cellWidth;
    CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
    CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:kContentFont]} context:nil].size;
    
    //底部空隙
    _cellHeight += textSize.height + ChatCellMargin;
     //   NSLog(@"cellHeight = %f",_cellHeight);
    return _cellHeight;
}

- (CGFloat)priCellHeight
{
    //如果计算过高度,直接返回
    if (_priCellHeight) return _priCellHeight;
    
    _priCellHeight = 10;
    NSString *content = self.content;
    //文字
    CGFloat textMaxW = self.priCellWidth;
    CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
    CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:kContentFont]} context:nil].size;
    
    //底部空隙
    _priCellHeight += textSize.height + 10;
//       NSLog(@"pricellHeight = %f",_priCellHeight);
    return _priCellHeight;
}
@end