GFRefreshControl
示例
为 ScrollView 和 TableView 提供自定义和可自定义的刷新控制动画。您可以使用自定义图片,并更改背景和图片颜色。
要运行示例项目,请先克隆仓库,然后从示例目录中先运行 pod install
。
安装
GFRefreshControl 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 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, [email protected]
许可协议
GFRefreshControl 遵循 MIT 许可协议。更多信息请参阅 LICENSE 文件。