自定义下拉刷新控件-CBStoreHouseRefreshControl

今天给大家介绍一个下拉自定义控件-CBStoreHouseRefreshControl


安装

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

1
pod  "CBStoreHouseRefreshControl"

当然你也可以直接把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;

}






  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值