UIScrollView
类的范畴,它添加了 bottomRefreshControl
属性,该属性可以被分配给 UIRefreshControl
类实例。它实现了向 UITableView
或 UICollectionView
添加原生 iOS 底部下拉刷新控件的能力。与顶部刷新控件完美配合(见示例项目)。对于刷新底部含有最新条目的表格和集合视图非常有用。例如在聊天应用中。
CocoaPods 是向项目中添加 CCBottomRefreshControl
的推荐方式。
这里是一个安装 CCBottomRefreshControl
的示例 Podfile。
platform :ios, '7.0'
pod 'CCBottomRefreshControl'
创建一个普通的 UIRefreshControl
类实例,并将额外的 UITableView/UICollectionView
属性 bottomRefreshControl
分配给它。
UIRefreshControl
类的额外属性 triggerVerticalOffset
允许您指定一个垂直偏移量,当达到此偏移量时将触发刷新。默认值为 120。
#import <CCBottomRefreshControl/UIScrollView+BottomRefreshControl.h>
...
UIRefreshControl *refreshControl = [UIRefreshControl new];
refreshControl.triggerVerticalOffset = 100.;
[refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
self.tableView.bottomRefreshControl = refreshControl;
- (void)refresh {
// Do refresh stuff here
}
CCBottomRefreshControl 在 MIT 许可下发布。见 LICENSE