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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// PasengerCell.m
// XFFruit
//
// Created by 陈俊俊 on 15/11/8.
// Copyright © 2015年 Xummer. All rights reserved.
//
#import "PasengerCell.h"
#define Sale_Cell_Height 50
#define Left_Width 85
#define Left_margin 10
@interface PasengerCell ()
{
BOOL hasBuildLayout; // default, NO;
}
@property (nonatomic, strong) UILabel *dqLabel;
@property (nonatomic, strong) UILabel *saleLabel;
@property (nonatomic, strong) UILabel *lastWeekLabel;
@property (nonatomic, strong) UIFont *textFont;
@property (nonatomic, strong) UIFont *titleFont;
@property (nonatomic, strong) NSIndexPath *indexPath;
@end
@implementation PasengerCell
+ (CGFloat)cellHeight
{
return Sale_Cell_Height;
}
#pragma mark - build view
- (void)buildLayout
{
if(hasBuildLayout) {
return;
}
hasBuildLayout = YES;
if(self.textFont == nil) {
self.textFont = [UIFont systemFontOfSize:13];
}
if(self.titleFont == nil) {
self.titleFont = [UIFont systemFontOfSize:17];
}
//页面布局
[self createView];
}
//创建视图
- (void)createView
{
CGRect rect = CGRectMake(Left_margin,0, Left_Width, Sale_Cell_Height);
self.dqLabel = [IBTCommon labelWithTitle:@"0101第一片区" frame:rect textFont:self.textFont];
self.dqLabel.textColor = GXF_NAVIGAYION_COLOR;
[self.contentView addSubview:self.dqLabel];
CGFloat width = (ScreenSize.width - self.dqLabel.width)/2;
rect = CGRectMake(self.dqLabel.right , 0, width, Sale_Cell_Height);
self.saleLabel = [IBTCommon labelWithTitle:@"60.0" frame:rect textFont:self.textFont];
self.saleLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.saleLabel];
rect = CGRectMake(self.saleLabel.right, 0, width, Sale_Cell_Height);
self.lastWeekLabel = [IBTCommon labelWithTitle:@"14.20%" frame:rect textFont:self.textFont];
self.lastWeekLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.lastWeekLabel];
UILabel *lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(10, Sale_Cell_Height - 1, ScreenSize.width - 10 * 2, 1))];
lineLabel.backgroundColor = GXF_LINE_COLOR;
[self.contentView addSubview:lineLabel];
}
#pragma mark - update view
- (void)updateCellWith:(id)policy index:(NSIndexPath *)indexPath
{
self.indexPath = indexPath;
[self buildLayout];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end