库命名为PSRefresh,支持UIScrollView及所有UIScrollView的子类控件,UITableView(横向的tableVIew)及UICollectionView等皆可。
支持自定义文字,支持自定义gif图,可设置是否为最后一页。
本文一共提供了三种样式,分别是普通样式、gif加载样式(带有状态label)、git加载样式(不带有状态label)。
Demo展示如下:
使用时导入 "UIScrollView+PSRefresh.h" 文件即可,文件中提供的属性及接口如下:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
@interface UIScrollView (PSRefresh)
/**
* 是否是最后一页
*/
@property (nonatomic, assign) BOOL isLastPage;
/**
* header背景色
*/
@property (nonatomic, strong) UIColor *refreshHeaderBackgroundColor;
/**
* footer背景色
*/
@property (nonatomic, strong) UIColor *refreshFooterBackgroundColor;
/**
* header 字体
*/
@property (nonatomic, strong) UIFont *refreshHeaderFont;
/**
* header 字体颜色
*/
@property (nonatomic, strong) UIColor *refreshHeaderTextColor;
/**
* footer 字体
*/
@property (nonatomic, strong) UIFont *refreshFooterFont;
/**
* footer 字体颜色
*/
@property (nonatomic, strong) UIColor *refreshFooterTextColor;
/**
* ********************** 以下是调用的方法 **********************
*/
/**
* 普通的刷新及加载
*/
- (void)addRefreshHeaderWithClosure:(PSRefreshClosure)closure;
- (void)addRefreshFooterWithClosure:(PSRefreshClosure)closure;
/**
* gif 图刷新及加载(带有状态提示)
*/
- (void)addGifRefreshHeaderWithClosure:(PSRefreshClosure)closure;
- (void)addGifRefreshFooterWithClosure:(PSRefreshClosure)closure;
/**
* gif 图刷新及加载(不带有状态提示)
*/
- (void)addGifRefreshHeaderNoStatusWithClosure:(PSRefreshClosure)closure;
- (void)addGifRefreshFooterNoStatusWithClosure:(PSRefreshClosure)closure;
/**
* ****************** 以下三个方法是对上面方法的再次封装 ******************
*/
/**
* 普通的刷新及加载
*/
- (void)addRefreshHeaderWithClosure:(PSRefreshClosure)headerClosure
addRefreshFooterWithClosure:(PSRefreshClosure)footerClosure;
/**
* gif 图刷新及加载(带有状态提示)
*/
- (void)addGifRefreshHeaderWithClosure:(PSRefreshClosure)headerClosure
addGifRefreshFooterWithClosure:(PSRefreshClosure)footerClosure;
/**
* gif 图刷新及加载(不带有状态提示)
*/
- (void)addGifRefreshHeaderNoStatusWithClosure:(PSRefreshClosure)headerClosure
addGifRefreshFooterNoStatusWithClosure:(PSRefreshClosure)footerClosure;
/**
* 结束刷新
*/
- (void)endRefreshing;
@end
|
调用时可以有两种方法,可以同时添加头部控件和尾部控件,也可以分别进行添加,方法如下(这里只列举一种调用方法,只是为了展示两种不同的调用方式):
(1) 同时添加:
?
|
1
2
3
4
5
6
7
8
9
10
|
- (void)normalDemo {
WeakSelf(self)
[_collectionView addRefreshHeaderWithClosure:^{
// 刷新操作
[weakSelf refreshData];
} addRefreshFooterWithClosure:^{
// 加载操作
[weakSelf loadingData];
}];
}
|
(2) 分别添加:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
|
- (void)normalDemo {
WeakSelf(self)
[_collectionView addRefreshHeaderWithClosure:^{
// 刷新操作
[weakSelf refreshData];
}];
[_collectionView addRefreshFooterWithClosure:^{
// 加载操作
[weakSelf loadingData];
}];
}
|
总结
调用方式大致和MJRefresh相同,针对具体项目大家可以进行相应的调整。以上就是本文的全部内容,希望对大家开发IOS有所帮助。
相关文章
猜你喜欢
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
- 64M VPS建站:能否支持高流量网站运行? 2025-06-10
- 64M VPS建站:怎样选择合适的域名和SSL证书? 2025-06-10
- 64M VPS建站:怎样优化以提高网站加载速度? 2025-06-10
- 64M VPS建站:是否适合初学者操作和管理? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-25 80
-
2025-05-29 62
-
2025-05-29 67
-
2025-05-25 99
-
2025-05-29 33
热门评论


