-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathViewController.m
More file actions
62 lines (49 loc) · 1.69 KB
/
ViewController.m
File metadata and controls
62 lines (49 loc) · 1.69 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
51
52
53
54
55
56
57
58
59
60
61
62
//
// ViewController.m
// WDHorizontalTableView
//
// Created by 何伟东 on 2018/2/23.
// Copyright © 2018年 何伟东. All rights reserved.
//
#import "ViewController.h"
#import <Masonry/Masonry.h>
#import <WDKit/WDKit.h>
#import "WDHorizontalTableView.h"
@interface ViewController ()<WDHorizontalTableViewDataSource,WDHorizontalTableViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
WDHorizontalTableView *horizontalTableView = [[WDHorizontalTableView alloc] init];
[horizontalTableView.scrollView setPagingEnabled:YES];
[horizontalTableView setItemWidth:SCREEN_WIDTH];
[horizontalTableView setDataSource:self];
[horizontalTableView setDelegate:self];
[self.view addSubview:horizontalTableView];
[horizontalTableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.bottom.mas_equalTo(0);
}];
[horizontalTableView reloadData];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma WDHorizontalTableViewDataSource
-(WDHorizontalTableViewItem *_Nonnull)contentView:(WDHorizontalTableView*_Nullable)horizontalTableView fromIndex:(NSInteger)index{
WDHorizontalTableViewItem *item = [horizontalTableView dequeueReusableItem];
if (index%2 == 0) {
[item setBackgroundColor:[UIColor blueColor]];
}else{
[item setBackgroundColor:[UIColor greenColor]];
}
return item;
}
-(NSInteger)numberOfItemCount{
return 10;
}
#pragma WDHorizontalTableViewDelegate
-(void)swithPageIndex:(NSInteger)idex{
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end