ComDynModel.m
1.1 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
//
// ComDynModel.m
// DreamSleep
//
// Created by peter on 2022/9/27.
//
#import "ComDynModel.h"
@implementation ComDynModel
- (CGFloat)contentHeight {
CGFloat contentW = kScreenWidth - 60;
NSString *content = self.content;
CGFloat contentH = [UILabel getHeightByWidth:contentW text:content font:SysFont(14)];
return contentH > 100 ? 100 : contentH;
}
- (CGFloat)imgHeight {
if (self.imgUrls) {
if (iPhone5) {
return 100;
} else {
switch (self.imgUrls.count) {
case 1: case 2:
return 150;
break;
case 3:
return 95;
break;
default:
return 0;
break;
}
}
}
return 0;
}
- (CGFloat)cellHeight {
CGFloat topH = 67;
CGFloat bottomH = (self.imgUrls && self.imgUrls.count) ? 52 : 56;
CGFloat contentH = [self contentHeight];
CGFloat imgTextSpace = (self.imgUrls && self.imgUrls.count) ? 12 : 0;
CGFloat imgH = [self imgHeight];
return topH + bottomH + contentH + imgTextSpace + imgH;
}
@end