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
//
// prizeOrderDetailsModel.m
// Lighting
//
// Created by 曹云霄 on 2016/11/29.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "prizeOrderDetailsModel.h"
@implementation prizeOrderDetailsModel
- (CGFloat)giftHeight
{
if (!_giftHeight) {
_giftHeight = [self calculateGiftNeedHeight:self.details];
}
return _giftHeight;
}
#pragma mark - 计算礼品显示需要高度
- (CGFloat)calculateGiftNeedHeight:(NSArray<TOPrizeBillDetailsEntity *>*)gifts
{
CGFloat height = 0;
NSInteger count = gifts.count;
CGFloat itemHeight = 100;
CGFloat interval = 20;
if (count <= 2) {
height += itemHeight+interval *2;
}else if (count %2 == 0 || count%2 == 1){
if (count %2 == 1) {
count += 1;
}
height += (count/2)*itemHeight + ((count/2)+1)*interval;
}
return height;
}
@end