Custom and customizable refresh control animation for ScrollView and TableView. Custom and customizable refresh control animation for ScrollView and TableView. You can use your custom image and change backgrounf, image colors.
To run the example project, clone the repo, and run pod install
from the Example directory first.
GFRefreshControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'GFRefreshControl'
- (void)initRefreshControl:(UIScrollView*)scrollView {
refreshControl = [[GFRefreshImageControl alloc] initWithTableView:scrollView protocol:self selector:@selector(callRequest) target:self];
[scrollView addSubview:refreshControl];
// customizable
[refreshControl setImage:[UIImage imageNamed:@"test"]];
[refreshControl setFillImageBackgroundColor:[UIColor groupTableViewBackgroundColor]];
[refreshControl setFillColor:[UIColor redColor]];
// [refreshControl setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
}
- (void)callRequest {
NSLog(@"callRequest");
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self->refreshControl endRefreshing];
});
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[refreshControl updateTableBounds:_scrollView.frame.size];
}
#pragma mark - GFRefreshControlProtocol
- (UIScrollView *)getScrollViewForRefreshControl {
return _scrollView;
}
guidosette, guido.fanfani7@gmail.com
GFRefreshControl is available under the MIT license. See the LICENSE file for more info.