Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhangao0086/dkstickyfooterview
A simple UIView with sticky.
https://github.com/zhangao0086/dkstickyfooterview
Last synced: 29 days ago
JSON representation
A simple UIView with sticky.
- Host: GitHub
- URL: https://github.com/zhangao0086/dkstickyfooterview
- Owner: zhangao0086
- License: mit
- Created: 2015-05-08T11:04:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-26T07:09:35.000Z (about 9 years ago)
- Last Synced: 2024-05-09T19:57:07.732Z (6 months ago)
- Language: Objective-C
- Homepage:
- Size: 1.44 MB
- Stars: 9
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DKStickyFooterView
The footer view will stick to the bottom when scroll to the *contentOffset* of max or scroll up.# Easy to use
```objective-c
DKStickyFooterView *footerView = [[DKStickyFooterView alloc] initWithFrame:CGRectMake(0, 0, 0, 44)];
[self.tableView addSubview:footerView];
```## Set *zPosition* if added to UITableView
```objective-c
footerView.layer.zPosition = 1;
```# Based on Key-Value Observing
```objective-c
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if ([keyPath isEqualToString:KEY_PATH_CONTENTOFFSET]) {
CGFloat newOffsetY = [[change valueForKey:NSKeyValueChangeNewKey] CGPointValue].y;
CGFloat oldOffsetY = [[change valueForKey:NSKeyValueChangeOldKey] CGPointValue].y;
CGFloat delta = newOffsetY - oldOffsetY;
CGFloat totalDelta = self.beganContentOffset.y - newOffsetY;
[self updateYForContentOffset];
if (ABS(totalDelta) < MINIMUM_SCROLLING_LENGTH || ABS(delta) <= 0.5) {
return;
}if (delta > 0 && self.scrollView.contentOffset.y > 0.0
&& self.scrollView.contentOffset.y + self.scrollView.height < self.scrollView.contentSize.height) {
if (self.isShow) {
self.isShow = NO;
}
} else {
if (!self.isShow) {
self.isShow = YES;
}
}
[UIView animateWithDuration:ANIMATION_DURATION animations:^{
[self updateYForContentOffset];
}];
} else if ([keyPath isEqualToString:KEY_PATH_FRAME]) {
if (!self.isShow) {
[self updateYForContentOffset];
}
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}```
# Licence
This code is distributed under the terms and conditions of the MIT license.