chatMsgModel.m
1.52 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// 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