原创Blog,转载请注明出处
blog.csdn.net/hello_hwc
我的Github
https://github.com/wenchenhuang/WCPullRefreshControl
前言:
写IOS代码有段时间了,是时候写几个Github的库了,即锻炼了自己,又能够帮助需要的人。
这个库是一个下拉刷新库,自己用了10个小时左右的时间开发的,做了屏幕适配,旋转适配,自己设计了一些动画,API设计改了3次。最后,第一个版本提交到Github了。
地址
几种效果图
特点:
使用起来很简单
例子一 用Block传递事件
这里使用默认的样式
@interface DemoTableview()<UIScrollViewDelegate>
@property (strong,nonatomic)WCSimplePullRefreshControl * pullRefresh;
@end
@implementation DemoTableview
-(void)viewDidLoad{
self.pullRefresh = [[WCSimplePullRefreshControl alloc] initWithScrollview:self.tableView Action:^{
[self performSelector:@selector(reset) withObject:nil afterDelay:2.0];
}];
}
-(void)reset{
[self.pullRefresh finishRefreshingSuccessully:YES];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
[self.pullRefresh updateWHenScrollDidEndDraging];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
[self.pullRefresh updateWhenScrollviewScroll];
}
方式二 用代理传递事件
定制化样式
@interface DemoTableview()<UIScrollViewDelegate,WCPullRefreshControlDelegate>
@property (strong,nonatomic)WCSimplePullRefreshControl * pullRefresh;
@end
@implementation DemoTableview
-(void)viewDidLoad{
self.pullRefresh = [[WCSimplePullRefreshControl alloc] initWithScrollview:self.tableView Action:NULL progressItem:WCProgressItemTypeMagicSquare refreshingItem:WCRefreshingItemTypeMagicSquare lastUpdate:nil showLastUpdate:NO textColor:[UIColor blueColor] itemColor:[UIColor grayColor] pullHeight:64];
self.pullRefresh.delegate = self;
}
-(void)reset{
[self.pullRefresh finishRefreshingSuccessully:YES];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
[self.pullRefresh updateWHenScrollDidEndDraging];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
[self.pullRefresh updateWhenScrollviewScroll];
}
-(void)DidStartRefreshingWithScrollview:(UIScrollView *)scrollview{
[self performSelector:@selector(reset) withObject:nil afterDelay:2.0];
}
@end
后续
如果发现bug,请在本博客留言,或者email: njuhwc@163.com
开发IOS库之下拉刷新-WCPullRefreshControl
原文地址:http://blog.csdn.net/hello_hwc/article/details/45060885