forked from Grouper/FlatUIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableViewController.m
More file actions
84 lines (66 loc) · 2.46 KB
/
TableViewController.m
File metadata and controls
84 lines (66 loc) · 2.46 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// TableViewController.m
// FlatUIKitExample
//
// Created by Maciej Swic on 2013-05-31.
//
//
#import "TableViewController.h"
#import "UITableViewCell+FlatUI.h"
#import "UIColor+FlatUI.h"
static NSString * const FUITableViewControllerCellReuseIdentifier = @"FUITableViewControllerCellReuseIdentifier";
@implementation TableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Table View";
//Set the separator color
self.tableView.separatorColor = [UIColor cloudsColor];
//Set the background color
self.tableView.backgroundColor = [UIColor cloudsColor];
self.tableView.backgroundView = nil;
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:FUITableViewControllerCellReuseIdentifier];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 7;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section % 2)
return 3;
else
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIRectCorner corners = 0;
if (tableView.style == UITableViewStyleGrouped) {
if ([tableView numberOfRowsInSection:indexPath.section] == 1) {
corners = UIRectCornerAllCorners;
} else if (indexPath.row == 0) {
corners = UIRectCornerTopLeft | UIRectCornerTopRight;
} else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section] - 1) {
corners = UIRectCornerBottomLeft | UIRectCornerBottomRight;
}
}
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:FUITableViewControllerCellReuseIdentifier];
[cell configureFlatCellWithColor:[UIColor greenSeaColor]
selectedColor:[UIColor cloudsColor]
roundingCorners:corners];
cell.cornerRadius = 5.f; //Optional
if (self.tableView.style == UITableViewStyleGrouped) {
cell.separatorHeight = 2.f; //Optional
} else {
cell.separatorHeight = 0.;
}
cell.textLabel.text = [NSString stringWithFormat:@"Section %ld Row %ld", (long)indexPath.section, (long)indexPath.row];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end