项目介绍:
项目简介
INSPullToRefresh
INSPullToRefresh是一个便于使用的非常简单的下拉刷新和无线滚动功能的UIScrollView集合。
使用方法
Objective-C
[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];
Swift
self.tableView.ins_addPullToRefreshWithHeight(60.0, handler: { scrollView in
let delayInSeconds: Int64 = 1
let popTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * Int64(NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue()) {
scrollView.ins_endPullToRefresh()
}
let defaultFrame = CGRectMake(0, 0, 24, 24)
let pullToRefresh = INSDefaultPullToRefresh(frame: defaultFrame, backImage: UIImage(named: "default_child"), frontImage: UIImage(named: "default_user"))
self.tableView.ins_pullToRefreshBackgroundView.delegate = pullToRefresh
self.tableView.ins_pullToRefreshBackgroundView.addSubview(pullToRefresh)
})
需要在自定义视图中处理INSPullToRefreshBackgroundViewDelegate方法
@protocol INSPullToRefreshBackgroundViewDelegate <NSObject>
@optional
-
(void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeState:(INSPullToRefreshBackgroundViewState)state;
-
(void)pullToRefreshBackgroundView:(INSPullToRefreshBackgroundView *)pullToRefreshBackgroundView didChangeTriggerStateProgress:(CGFloat)progress;
@end
github地址:https://github.com/inspace-io/INSPullToRefresh