/
DemoViewController.m
116 lines (94 loc) · 3.79 KB
/
DemoViewController.m
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
107
108
109
110
111
112
113
114
115
116
//
// ViewController.m
// StockView
//
// Created by Jezz on 2017/10/14.
// Copyright © 2017年 Jezz. All rights reserved.
//
#import "DemoViewController.h"
#import "JJStockView.h"
@interface DemoViewController ()<StockViewDataSource,StockViewDelegate>
@property(nonatomic,readwrite,strong)JJStockView* stockView;
@end
@implementation DemoViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"股票表格";
self.stockView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
[self.view addSubview:self.stockView];
}
#pragma mark - Stock DataSource
- (NSUInteger)countForStockView:(JJStockView*)stockView{
return 30;
}
- (UIView*)titleCellForStockView:(JJStockView*)stockView atRowPath:(NSUInteger)row{
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
label.text = [NSString stringWithFormat:@"标题:%ld",row];
label.textColor = [UIColor grayColor];
label.backgroundColor = [UIColor colorWithRed:223.0f/255.0 green:223.0f/255.0 blue:223.0f/255.0 alpha:1.0];
label.textAlignment = NSTextAlignmentCenter;
return label;
}
- (UIView*)contentCellForStockView:(JJStockView*)stockView atRowPath:(NSUInteger)row{
UIView* bg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1000, 30)];
bg.backgroundColor = row % 2 == 0 ?[UIColor whiteColor] :[UIColor colorWithRed:240.0f/255.0 green:240.0f/255.0 blue:240.0f/255.0 alpha:1.0];
for (int i = 0; i < 10; i++) {
// UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(i * 100, 0, 100, 30)];
// [button setTitle:[NSString stringWithFormat:@"内容:%d",i] forState:UIControlStateNormal];
// [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
// [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
// button.titleLabel.textAlignment = NSTextAlignmentCenter;
// button.tag = i;
// [bg addSubview:button];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(i * 100, 0, 100, 30)];
label.text = [NSString stringWithFormat:@"内容:%d",i];
label.textAlignment = NSTextAlignmentCenter;
[bg addSubview:label];
}
return bg;
}
#pragma mark - Stock Delegate
- (CGFloat)heightForCell:(JJStockView*)stockView atRowPath:(NSUInteger)row{
return 30.0f;
}
- (UIView*)headRegularTitle:(JJStockView*)stockView{
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
label.text = @"标题";
label.backgroundColor = [UIColor whiteColor];
label.textColor = [UIColor grayColor];
label.textAlignment = NSTextAlignmentCenter;
return label;
}
- (UIView*)headTitle:(JJStockView*)stockView{
UIView* bg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1000, 40)];
bg.backgroundColor = [UIColor colorWithRed:223.0f/255.0 green:223.0f/255.0 blue:223.0f/255.0 alpha:1.0];
for (int i = 0; i < 10; i++) {
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(i * 100, 0, 100, 40)];
label.text = [NSString stringWithFormat:@"标题:%d",i];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor grayColor];
[bg addSubview:label];
}
return bg;
}
- (CGFloat)heightForHeadTitle:(JJStockView*)stockView{
return 40.0f;
}
- (void)didSelect:(JJStockView*)stockView atRowPath:(NSUInteger)row{
NSLog(@"DidSelect Row:%ld",row);
}
#pragma mark - Button Action
- (void)buttonAction:(UIButton*)sender{
NSLog(@"Button Row:%ld",sender.tag);
}
#pragma mark - Get
- (JJStockView*)stockView{
if(_stockView != nil){
return _stockView;
}
_stockView = [JJStockView new];
_stockView.dataSource = self;
_stockView.delegate = self;
return _stockView;
}
@end