INSPullToRefresh was written by Michał Zaborowski for inspace.io
INSPullToRefresh
is a simple to use very generic pull-to-refresh and infinite scrolling functionalities as a UIScrollView category.
There are a lot of of pull to refresh views. We've never found one we are happy with. We always end up customizing one, so we decided to write one that's highly generic. You can just write you view and it to the content of pull to refresh or infinite scroll container view.
We wrote couple samples that can be found in popular apps like Facebook, Vine, Twitter etc.
[self.tableView ins_addPullToRefreshWithHeight:60.0 handler:^(UIScrollView *scrollView) {
int64_t delayInSeconds = 1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[scrollView ins_endPullToRefresh];
});
}];
CGRect defaultFrame = CGRectMake(0, 0, 24, 24);
UIView <INSPullToRefreshBackgroundViewDelegate> *pullToRefresh = [[INSDefaultPullToRefresh alloc] initWithFrame:defaultFrame backImage:[UIImage imageNamed:@"circleLight"] frontImage:[UIImage imageNamed:@"circleDark"]];
self.tableView.ins_pullToRefreshBackgroundView.delegate = pullToRefresh;
[self.tableView.ins_pullToRefreshBackgroundView addSubview:pullToRefresh];
#pragma mark - dealloc
- (void)dealloc {
[self.tableView ins_removeInfinityScroll];
[self.tableView ins_removePullToRefresh];
}
All you need to do is handle two INSPullToRefreshBackgroundViewDelegate methods in your custom view.
@protocol INSPullToRefreshBackgroundViewDelegate <NSObject>
@optional
- (void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeState:(INSPullToRefreshBackgroundViewState)state;
- (void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeTriggerStateProgress:(CGFloat)progress;
@end
Add the following to your Podfile
and run $ pod install
.
pod 'INSPullToRefresh'
If you don't have CocoaPods installed, you can learn how to do so here.
INSElectronicProgramGuideLayout
uses ARC.
The MIT License (MIT)
Copyright (c) 2015 inspace.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.