您的位置:首页 > 其它

自定义下拉刷新控件-CBStoreHouseRefreshControl

2016-03-11 17:35 295 查看
今天给大家介绍一个下拉自定义控件-CBStoreHouseRefreshControl



安装

CBStoreHouseRefreshControl依赖于CocoaPods,通过在你的Podfile中添加下面这行命令来安装:

当然你也可以直接把CBStoreHouseRefreshControl (.h .m) 和 BarItem (.h .m)文件直接拖到你的工程中去。

同时再倒入文件的时候也可以将案例中的plist文件导入,或者自己定义,否则没有效果。

用法

在你需要处理的控制器里面声明对象和方法名,这个方法已经在CBStoreHouseRefreshControl这个类里面实现了,所以不需要我们去实现,只是声明一下即可。

将一下代码拷贝到你的.m文件中。

//注:_tbView 使我们需要处理的tableview

self.storeHouseRefreshControl = [CBStoreHouseRefreshControl
attachToScrollView:_tbView
target:self refreshAction:@selector(refreshTriggered:)
plist:@"storehouse"];

    

最后别放了将一下方法导入你的.m中,如果你已经处理过scrollView的这些方法,就只需要补充一下就可以了。

//下拉刷新

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    [self.storeHouseRefreshControl
scrollViewDidScroll];

}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate

{

    [self.storeHouseRefreshControl
scrollViewDidEndDragging];

}

- (void)refreshTriggered:(id)sender

{

    [self
performSelector:@selector(finishRefreshControl)
withObject:nil
afterDelay:3
inModes:@[NSRunLoopCommonModes]];

}

- (void)finishRefreshControl

{

    [self.storeHouseRefreshControl
finishingLoading];

}

-(UIStatusBarStyle)preferredStatusBarStyle

{

    return
UIStatusBarStyleLightContent;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息