-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeaderInsetTableView.m
More file actions
92 lines (65 loc) · 2.36 KB
/
HeaderInsetTableView.m
File metadata and controls
92 lines (65 loc) · 2.36 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
85
86
87
88
89
90
91
92
//
// HeaderInsetTableView.m
// Dealabs
//
// Created by Raphaël Pinto on 15/10/2014.
// Copyright (c) 2014 HUME Network. All rights reserved.
//
#import "HeaderInsetTableView.h"
#import "HeaderInsetTableView.h"
@interface HeaderInsetTableView ()
{
BOOL shouldManuallyLayoutHeaderViews;
}
- (void) layoutHeaderViews;
@end
@implementation HeaderInsetTableView
@synthesize headerViewInsets;
#pragma mark -
#pragma mark Super
- (void) layoutSubviews
{
[super layoutSubviews];
if(shouldManuallyLayoutHeaderViews)
[self layoutHeaderViews];
}
#pragma mark -
#pragma mark Self
- (void) setHeaderViewInsets:(UIEdgeInsets)_headerViewInsets
{
/* headerViewInsets = _headerViewInsets;
shouldManuallyLayoutHeaderViews = !UIEdgeInsetsEqualToEdgeInsets(headerViewInsets, UIEdgeInsetsZero);
[self setNeedsLayout];*/
}
#pragma mark -
#pragma mark Private
- (void) layoutHeaderViews
{
/* const NSUInteger numberOfSections = self.numberOfSections;
const UIEdgeInsets contentInset = self.contentInset;
const CGPoint contentOffset = self.contentOffset;
const CGFloat sectionViewMinimumOriginY = contentOffset.y + contentInset.top + headerViewInsets.top;
// Layout each header view
for(NSUInteger section = 0; section < numberOfSections; section++)
{
UIView* sectionView = [self headerViewForSection:section];
if(sectionView == nil)
continue;
const CGRect sectionFrame = [self rectForSection:section];
CGRect sectionViewFrame = sectionView.frame;
sectionViewFrame.origin.y = ((sectionFrame.origin.y < sectionViewMinimumOriginY) ? sectionViewMinimumOriginY : sectionFrame.origin.y);
// If it's not last section, manually 'stick' it to the below section if needed
if(section < numberOfSections - 1)
{
const CGRect nextSectionFrame = [self rectForSection:section + 1];
if(CGRectGetMaxY(sectionViewFrame) > CGRectGetMinY(nextSectionFrame))
sectionViewFrame.origin.y = nextSectionFrame.origin.y - sectionViewFrame.size.height;
}
if (sectionViewFrame.origin.y < self.contentOffset.y)
{
sectionViewFrame.origin.y = self.contentOffset.y;
}
[sectionView setFrame:sectionViewFrame];
}*/
}
@end