栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > iOS

iOS功能实现之列表的横向刷新加载

iOS 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

iOS功能实现之列表的横向刷新加载

库命名为PSRefresh,支持UIScrollView及所有UIScrollView的子类控件,UITableView(横向的tableVIew)及UICollectionView等皆可。

支持自定义文字,支持自定义gif图,可设置是否为最后一页。

本文一共提供了三种样式,分别是普通样式gif加载样式(带有状态label)、git加载样式(不带有状态label)。

Demo展示如下:


使用时导入 "UIScrollView+PSRefresh.h" 文件即可,文件中提供的属性及接口如下:

@interface UIScrollView (PSRefresh)


@property (nonatomic, assign) BOOL isLastPage;


@property (nonatomic, strong) UIColor *refreshHeaderBackgroundColor;


@property (nonatomic, strong) UIColor *refreshFooterBackgroundColor;


@property (nonatomic, strong) UIFont *refreshHeaderFont;


@property (nonatomic, strong) UIColor *refreshHeaderTextColor;


@property (nonatomic, strong) UIFont *refreshFooterFont;


@property (nonatomic, strong) UIColor *refreshFooterTextColor;



- (void)addRefreshHeaderWithClosure:(PSRefreshClosure)closure;

- (void)addRefreshFooterWithClosure:(PSRefreshClosure)closure;


- (void)addGifRefreshHeaderWithClosure:(PSRefreshClosure)closure;

- (void)addGifRefreshFooterWithClosure:(PSRefreshClosure)closure;


- (void)addGifRefreshHeaderNoStatusWithClosure:(PSRefreshClosure)closure;

- (void)addGifRefreshFooterNoStatusWithClosure:(PSRefreshClosure)closure;



- (void)addRefreshHeaderWithClosure:(PSRefreshClosure)headerClosure
  addRefreshFooterWithClosure:(PSRefreshClosure)footerClosure;


- (void)addGifRefreshHeaderWithClosure:(PSRefreshClosure)headerClosure
  addGifRefreshFooterWithClosure:(PSRefreshClosure)footerClosure;


- (void)addGifRefreshHeaderNoStatusWithClosure:(PSRefreshClosure)headerClosure
  addGifRefreshFooterNoStatusWithClosure:(PSRefreshClosure)footerClosure;


- (void)endRefreshing;

@end

调用时可以有两种方法,可以同时添加头部控件和尾部控件,也可以分别进行添加,方法如下(这里只列举一种调用方法,只是为了展示两种不同的调用方式):

(1) 同时添加:

- (void)normalDemo {
 WeakSelf(self)
 [_collectionView addRefreshHeaderWithClosure:^{
  // 刷新操作
  [weakSelf refreshData];
 } addRefreshFooterWithClosure:^{
  // 加载操作
  [weakSelf loadingData];
 }];
}

(2) 分别添加:

- (void)normalDemo {
 WeakSelf(self)
 [_collectionView addRefreshHeaderWithClosure:^{
  // 刷新操作
  [weakSelf refreshData];
 }];

 [_collectionView addRefreshFooterWithClosure:^{
  // 加载操作
  [weakSelf loadingData];
 }];
}

总结

调用方式大致和MJRefresh相同,针对具体项目大家可以进行相应的调整。以上就是本文的全部内容,希望对大家开发IOS有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/167272.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号