8000 做空的下拉刷新 · newcoderzhang/LuaViewSDK@d8f9f64 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit d8f9f64

Browse files
author
城西
committed
做空的下拉刷新
1 parent effb5ec commit d8f9f64

File tree

9 files changed

+637
-0
lines changed

9 files changed

+637
-0
lines changed

IOS/LuaViewSDK.xcodeproj/project.pbxproj

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,18 @@
295295
914D5F3B1DD3275D00CEA3FF /* LVClassInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 914D5F391DD3275D00CEA3FF /* LVClassInfo.h */; };
296296
914D5F3C1DD3275D00CEA3FF /* LVClassInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 914D5F3A1DD3275D00CEA3FF /* LVClassInfo.m */; };
297297
914D5F3D1DD3276400CEA3FF /* LVClassInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 914D5F3A1DD3275D00CEA3FF /* LVClassInfo.m */; };
298+
91695AA91E11004B0088EFD6 /* UIScrollView+LVRefresh.h in Headers */ = {isa = PBXBuildFile; fileRef = 91695AA11E11004B0088EFD6 /* UIScrollView+LVRefresh.h */; };
299+
91695AAA1E11004B0088EFD6 /* UIScrollView+LVRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA21E11004B0088EFD6 /* UIScrollView+LVRefresh.m */; };
300+
91695AAB1E11004B0088EFD6 /* UIScrollView+LVRefresh.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA21E11004B0088EFD6 /* UIScrollView+LVRefresh.m */; };
301+
91695AAC1E11004B0088EFD6 /* LVRefreshConst.h in Headers */ = {isa = PBXBuildFile; fileRef = 91695AA31E11004B0088EFD6 /* LVRefreshConst.h */; };
302+
91695AAD1E11004B0088EFD6 /* LVRefreshConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA41E11004B0088EFD6 /* LVRefreshConst.m */; };
303+
91695AAE1E11004B0088EFD6 /* LVRefreshConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA41E11004B0088EFD6 /* LVRefreshConst.m */; };
304+
91695AAF1E11004B0088EFD6 /* LVRefreshComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 91695AA51E11004B0088EFD6 /* LVRefreshComponent.h */; };
305+
91695AB01E11004B0088EFD6 /* LVRefreshComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA61E11004B0088EFD6 /* LVRefreshComponent.m */; };
306+
91695AB11E11004B0088EFD6 /* LVRefreshComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA61E11004B0088EFD6 /* LVRefreshComponent.m */; };
307+
91695AB21E11004B0088EFD6 /* LVRefreshHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 91695AA71E11004B0088EFD6 /* LVRefreshHeader.h */; };
308+
91695AB31E11004B0088EFD6 /* LVRefreshHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA81E11004B0088EFD6 /* LVRefreshHeader.m */; };
309+
91695AB41E11004B0088EFD6 /* LVRefreshHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 91695AA81E11004B0088EFD6 /* LVRefreshHeader.m */; };
298310
91C55C721DD07185000BCB0B /* LVFlowLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 91C55C701DD07185000BCB0B /* LVFlowLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
299311
91C55C731DD07185000BCB0B /* LVFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C55C711DD07185000BCB0B /* LVFlowLayout.m */; };
300312
91C55C741DD07DAF000BCB0B /* LVFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C55C711DD07185000BCB0B /* LVFlowLayout.m */; };
@@ -557,6 +569,14 @@
557569
91232AAB1DAB67FC00536E0C /* LVWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVWebView.m; sourceTree = "<group>"; };
558570
914D5F391DD3275D00CEA3FF /* LVClassInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVClassInfo.h; sourceTree = "<group>"; };
559571
914D5F3A1DD3275D00CEA3FF /* LVClassInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVClassInfo.m; sourceTree = "<group>"; };
572+
91695AA11E11004B0088EFD6 /* UIScrollView+LVRefresh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+LVRefresh.h"; sourceTree = "<group>"; };
573+
91695AA21E11004B0088EFD6 /* UIScrollView+LVRefresh.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+LVRefresh.m"; sourceTree = "<group>"; };
574+
91695AA31E11004B0088EFD6 /* LVRefreshConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVRefreshConst.h; sourceTree = "<group>"; };
575+
91695AA41E11004B0088EFD6 /* LVRefreshConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVRefreshConst.m; sourceTree = "<group>"; };
576+
91695AA51E11004B0088EFD6 /* LVRefreshComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVRefreshComponent.h; sourceTree = "<group>"; };
577+
91695AA61E11004B0088EFD6 /* LVRefreshComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVRefreshComponent.m; sourceTree = "<group>"; };
578+
91695AA71E11004B0088EFD6 /* LVRefreshHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVRefreshHeader.h; sourceTree = "<group>"; };
579+
91695AA81E11004B0088EFD6 /* LVRefreshHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVRefreshHeader.m; sourceTree = "<group>"; };
560580
9171D4A21AADD0300040DAA3 /* LVLongPressGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVLongPressGesture.h; sourceTree = "<group>"; };
561581
9171D4A31AADD0300040DAA3 /* LVLongPressGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVLongPressGesture.m; sourceTree = "<group>"; };
562582
91882E891AAD45A400107DFC /* LVPinchGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVPinchGesture.h; sourceTree = "<group>"; };
@@ -752,6 +772,7 @@
752772
844317A01BC6194700968368 /* container */ = {
753773
isa = PBXGroup;
754774
children = (
775+
91695AA01E11003E0088EFD6 /* refresh */,
755776
84799AF31BAFECA00070E214 /* LVPagerView.h */,
756777
84799AF41BAFECA00070E214 /* LVPagerView.m */,
757778
84799AF81BAFEFDA0070E214 /* LVPagerViewCell.h */,
@@ -1068,6 +1089,21 @@
10681089
name = Frameworks;
10691090
sourceTree = "<group>";
10701091
};
1092+
91695AA01E11003E0088EFD6 /* refresh */ = {
1093+
isa = PBXGroup;
1094+
children = (
1095+
91695AA11E11004B0088EFD6 /* UIScrollView+LVRefresh.h */,
1096+
91695AA21E11004B0088EFD6 /* UIScrollView+LVRefresh.m */,
1097+
91695AA31E11004B0088EFD6 /* LVRefreshConst.h */,
1098+
91695AA41E11004B0088EFD6 /* LVRefreshConst.m */,
1099+
91695AA51E11004B0088EFD6 /* LVRefreshComponent.h */,
1100+
91695AA61E11004B0088EFD6 /* LVRefreshComponent.m */,
1101+
91695AA71E11004B0088EFD6 /* LVRefreshHeader.h */,
1102+
91695AA81E11004B0088EFD6 /* LVRefreshHeader.m */,
1103+
);
1104+
name = refresh;
1105+
sourceTree = "<group>";
1106+
};
10711107
91ACCE741AC530CA0034D9B3 /* lvdebug */ = {
10721108
isa = PBXGroup;
10731109
children = (
@@ -1126,6 +1162,7 @@
11261162
84C1D83B1C16C44A0058E974 /* UIView+LuaView.h in Headers */,
11271163
84C1D83C1C16C44A0058E974 /* LVButton.h in Headers */,
11281164
84C1D83D1C16C44A0058E974 /* LVImage.h in Headers */,
1165+
91695AAC1E11004B0088EFD6 /* LVRefreshConst.h in Headers */,
11291166
84C1D83E1C16C44A0058E974 /* LVNinePatchImage.h in Headers */,
11301167
84C1D83F1C16C44A0058E974 /* LVLabel.h in Headers */,
11311168
84C1D8401C16C44A0058E974 /* LVTextField.h in Headers */,
@@ -1147,6 +1184,7 @@
11471184
84C1D84F1C16C44A0058E974 /* LVToast.h in Headers */,
11481185
84C1D8501C16C44A0058E974 /* LVAnimate.h in Headers */,
11491186
84C1D8511C16C44B0058E974 /* LVStyledString.h in Headers */,
1187+
91695AAF1E11004B0088EFD6 /* LVRefreshComponent.h in Headers */,
11501188
84C1D8521C16C44B0058E974 /* LVTransform3D.h in Headers */,
11511189
BEEB28D51CA90EC200EC2D86 /* JUFLXLinearLayoutView.h in Headers */,
11521190
84C1D8531C16C44B0058E974 /* LVData.h in Headers */,
@@ -1158,6 +1196,7 @@
11581196
3CC1B5531C96B59D001DEEC0 /* LVZipArchive.h in Headers */,
11591197
84C1D8571C16C44B0058E974 /* LVGesture.h in Headers */,
11601198
84C1D8581C16C44B0058E974 /* LVLongPressGesture.h in Headers */,
1199+
91695AA91E11004B0088EFD6 /* UIScrollView+LVRefresh.h in Headers */,
11611200
BEEB28D11CA90EC200EC2D86 /* JUFLXNode.h in Headers */,
11621201
84C1D8591C16C44B0058E974 /* LVPanGesture.h in Headers */,
11631202
84C1D85A1C16C44B0058E974 /* LVPinchGesture.h in Headers */,
@@ -1191,6 +1230,7 @@
11911230
84C1D8731C16C44F0058E974 /* lVcode.h in Headers */,
11921231
84C1D8741C16C44F0058E974 /* lVconf.h in Headers */,
11931232
84C1D8751C16C4500058E974 /* lV B41A debug.h in Headers */,
1233+
91695AB21E11004B0088EFD6 /* LVRefreshHeader.h in Headers */,
11941234
84C1D8761C16C4500058E974 /* lVdo.h in Headers */,
11951235
84C1D8771C16C4500058E974 /* lVfunc.h in Headers */,
11961236
84C1D8781C16C4500058E974 /* lVgc.h in Headers */,
@@ -1393,6 +1433,7 @@
13931433
3CFF78001C74741400847C05 /* lViolib.c in Sources */,
13941434
3CFF78011C74741400847C05 /* lVlex.c in Sources */,
13951435
3CFF78021C74741400847C05 /* lVmathlib.c in Sources */,
1436+
91695AB11E11004B0088EFD6 /* LVRefreshComponent.m in Sources */,
13961437
3CFF78031C74741400847C05 /* lVmem.c in Sources */,
13971438
3CFF78041C74741400847C05 /* lVoadlib.c in Sources */,
13981439
3CFF78051C74741400847C05 /* lVobject.c in Sources */,
@@ -1413,8 +1454,10 @@
14131454
9112709C1DFAC65F001F8047 /* LVEvent.m in Sources */,
14141455
3CFF78111C74741400847C05 /* lVvm.c in Sources */,
14151456
3CFF78121C74741400847C05 /* lVzio.c in Sources */,
1457+
91695AB41E11004B0088EFD6 /* LVRefreshHeader.m in Sources */,
14161458
3CFF77B21C74740800847C05 /* LVPkgManager.m in Sources */,
14171459
3CFF77B41C74740800847C05 /* LVRSA.m in Sources */,
1460+
91695AAE1E11004B0088EFD6 /* LVRefreshConst.m in Sources */,
14181461
3CFF77B51C74740800847C05 /* LVDebugLua.m in Sources */,
14191462
BEEB28E01CA91B8900EC2D86 /* JUFLXNode.m in Sources */,
14201463
3CFF77B61C74740800847C05 /* LVDebuger.m in Sources */,
@@ -1435,6 +1478,7 @@
14351478
3CFF77C61C74740800847C05 /* LVPagerViewCell.m in Sources */,
14361479
3CFF77C71C74740800847C05 /* LVCollectionView.m in Sources */,
14371480
91F678861DF5209B0042D6FC /* LVCustomView.m in Sources */,
1481+
91695AAB1E11004B0088EFD6 /* UIScrollView+LVRefresh.m in Sources */,
14381482
3CFF77C81C74740800847C05 /* LVCollectionViewCell.m in Sources */,
14391483
3CFF77C91C74740800847C05 /* LVCollectionViewDelegate.m in Sources */,
14401484
3CFF77CA1C74740800847C05 /* LVScrollView.m in Sources */,
@@ -1528,6 +1572,7 @@
15281572
84C1D8211C16C4070058E974 /* lViolib.c in Sources */,
15291573
84C1D8221C16C4070058E974 /* lVlex.c in Sources */,
15301574
84C1D8231C16C4070058E974 /* lVmathlib.c in Sources */,
1575+
91695AB01E11004B0088EFD6 /* LVRefreshComponent.m in Sources */,
15311576
84C1D8241C16C4070058E974 /* lVmem.c in Sources */,
15321577
84C1D8251C16C4070058E974 /* lVoadlib.c in Sources */,
15331578
84C1D8261C16C4070058E974 /* lVobject.c in Sources */,
@@ -1548,8 +1593,10 @@
15481593
9112709B1DFAC65F001F8047 /* LVEvent.m in Sources */,
15491594
84E85C1C1C33B84B007DE3DF /* LVBundle.m in Sources */,
15501595
84C1D8321C16C4070058E974 /* lVvm.c in Sources */,
1596+
91695AB31E11004B0088EFD6 /* LVRefreshHeader.m in Sources */,
15511597
84C1D8331C16C4070058E974 /* lVzio.c in Sources */,
15521598
84C1D7D41C16C3F90058E974 /* LVPkgManager.m in Sources */,
1599+
91695AAD1E11004B0088EFD6 /* LVRefreshConst.m in Sources */,
15531600
84C1D7D61C16C3FA0058E974 /* LVRSA.m in Sources */,
15541601
BEEB28D21CA90EC200EC2D86 /* JUFLXNode.m in Sources */,
15551602
84C1D7D71C16C3FA0058E974 /* LVDebugLua.m in Sources */,
@@ -1570,6 +1617,7 @@
15701617
3C02D1DA1C31106E00213386 /* LVAnimator.m in Sources */,
15711618
84C1D7E71C16C3FA0058E974 /* LVPagerView.m in Sources */,
15721619
91F678851DF520920042D6FC /* LVCustomView.m in Sources */,
1620+
91695AAA1E11004B0088EFD6 /* UIScrollView+LVRefresh.m in Sources */,
15731621
84C1D7E81C16C3FA0058E974 /* LVPagerViewCell.m in Sources */,
15741622
84C1D7E91C16C3FA0058E974 /* LVCollectionView.m in Sources */,
15751623
84C1D7EA1C16C3FA0058E974 /* LVCollectionViewCell.m in Sources */,
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
#import <UIKit/UIKit.h>
3+
#import "LVRefreshConst.h"
4+
#import "UIScrollView+LVRefresh.h"
5+
6+
/** 刷新控件的状态 */
7+
typedef NS_ENUM(NSInteger, LVRefreshState) {
8+
/** 普通闲置状态 */
9+
LVRefreshStateIdle = 1,
10+
/** 松开就可以进行刷新的状态 */
11+
LVRefreshStatePulling,
12+
/** 正在刷新中的状态 */
13+
LVRefreshStateRefreshing,
14+
/** 即将刷新的状态 */
15+
LVRefreshStateWillRefresh,
16+
/** 所有数据加载完毕,没有更多的数据了 */
17+
LVRefreshStateNoMoreData
18+
};
19+
20+
/** 进入刷新状态的回调 */
21+
typedef void (^LVRefreshComponentRefreshingBlock)();
22+
23+
/** 刷新控件的基类 */
24+
@interface LVRefreshComponent : UIView
25+
{
26+
/** 记录scrollView刚开始的inset */
27+
UIEdgeInsets _scrollViewOriginalInset;
28+
/** 父控件 */
29+
__weak UIScrollView *_scrollView;
30+
}
31+
#pragma mark - 刷新回调
32+
/** 正在刷新的回调 */
33+
@property (copy, nonatomic) LVRefreshComponentRefreshingBlock refreshingBlock;
34+
/** 设置回调对象和回调方法 */
35+
- (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action;
36+
/** 回调对象 */
37+
@property (weak, nonatomic) id refreshingTarget;
38+
/** 回调方法 */
39+
@property (assign, nonatomic) SEL refreshingAction;
40+
/** 触发回调(交给子类去调用) */
41+
- (void)executeRefreshingCallback;
42+
43+
#pragma mark - 刷新状态控制
44+
/** 进入刷新状态 */
45+
- (void)beginRefreshing;
46+
/** 结束刷新状态 */
47+
- (void)endRefreshing;
48+
/** 是否正在刷新 */
49+
- (BOOL)isRefreshing;
50+
/** 刷新状态 一般交给子类内部实现 */
51+
@property (assign, nonatomic) LVRefreshState state;
52+
53+
#pragma mark - 交给子类去访问
54+
/** 记录scrollView刚开始的inset */
55+
@property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset;
56+
/** 父控件 */
57+
@property (weak, nonatomic, readonly) UIScrollView *scrollView;
58+
59+
#pragma mark - 交给子类们去实现
60+
/** 初始化 */
61+
- (void)prepare NS_REQUIRES_SUPER;
62+
/** 摆放子控件frame */
63+
- (void)placeSubviews NS_REQUIRES_SUPER;
64+
/** 当scrollView的contentOffset发生改变的时候调用 */
65+
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
66+
/** 当scrollView的contentSize发生改变的时候调用 */
67+
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
68+
/** 当scrollView的拖拽状态发生改变的时候调用 */
69+
- (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER;
70+
71+
72+
#pragma mark - 其他
73+
/** 拉拽的百分比(交给子类重写) */
74+
@property (assign, nonatomic) CGFloat pullingPercent;
75+
/** 根据拖拽比例自动切换透明度 */
76+
@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha;
77+
@end
78+
79+
@interface UILabel(LVRefresh)
80+
+ (instancetype)label;
81+
@end

0 commit comments

Comments
 (0)
0