commit | author | age
|
6e1425
|
1 |
// 代码地址: https://github.com/CoderMJLee/MJRefresh |
H |
2 |
// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 |
|
3 |
// MJRefreshComponent.h |
|
4 |
// MJRefreshExample |
|
5 |
// |
|
6 |
// Created by MJ Lee on 15/3/4. |
|
7 |
// Copyright (c) 2015年 小码哥. All rights reserved. |
|
8 |
// 刷新控件的基类 |
|
9 |
|
|
10 |
#import <UIKit/UIKit.h> |
|
11 |
#import "MJRefreshConst.h" |
|
12 |
#import "UIView+MJExtension.h" |
|
13 |
#import "UIScrollView+MJExtension.h" |
|
14 |
#import "UIScrollView+MJRefresh.h" |
|
15 |
|
|
16 |
/** 刷新控件的状态 */ |
|
17 |
typedef enum { |
|
18 |
/** 普通闲置状态 */ |
|
19 |
MJRefreshStateIdle = 1, |
|
20 |
/** 松开就可以进行刷新的状态 */ |
|
21 |
MJRefreshStatePulling, |
|
22 |
/** 正在刷新中的状态 */ |
|
23 |
MJRefreshStateRefreshing, |
|
24 |
/** 即将刷新的状态 */ |
|
25 |
MJRefreshStateWillRefresh, |
|
26 |
/** 所有数据加载完毕,没有更多的数据了 */ |
|
27 |
MJRefreshStateNoMoreData |
|
28 |
} MJRefreshState; |
|
29 |
|
|
30 |
/** 进入刷新状态的回调 */ |
|
31 |
typedef void (^MJRefreshComponentRefreshingBlock)(); |
|
32 |
|
|
33 |
/** 刷新控件的基类 */ |
|
34 |
@interface MJRefreshComponent : UIView |
|
35 |
{ |
|
36 |
/** 记录scrollView刚开始的inset */ |
|
37 |
UIEdgeInsets _scrollViewOriginalInset; |
|
38 |
/** 父控件 */ |
|
39 |
__weak UIScrollView *_scrollView; |
|
40 |
} |
|
41 |
#pragma mark - 刷新回调 |
|
42 |
/** 正在刷新的回调 */ |
|
43 |
@property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; |
|
44 |
/** 设置回调对象和回调方法 */ |
|
45 |
- (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; |
|
46 |
/** 回调对象 */ |
|
47 |
@property (weak, nonatomic) id refreshingTarget; |
|
48 |
/** 回调方法 */ |
|
49 |
@property (assign, nonatomic) SEL refreshingAction; |
|
50 |
/** 触发回调(交给子类去调用) */ |
|
51 |
- (void)executeRefreshingCallback; |
|
52 |
|
|
53 |
#pragma mark - 刷新状态控制 |
|
54 |
/** 进入刷新状态 */ |
|
55 |
- (void)beginRefreshing; |
|
56 |
/** 结束刷新状态 */ |
|
57 |
- (void)endRefreshing; |
|
58 |
/** 是否正在刷新 */ |
|
59 |
- (BOOL)isRefreshing; |
|
60 |
/** 刷新状态 一般交给子类内部实现 */ |
|
61 |
@property (assign, nonatomic) MJRefreshState state; |
|
62 |
|
|
63 |
#pragma mark - 交给子类去访问 |
|
64 |
/** 记录scrollView刚开始的inset */ |
|
65 |
@property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; |
|
66 |
/** 父控件 */ |
|
67 |
@property (weak, nonatomic, readonly) UIScrollView *scrollView; |
|
68 |
|
|
69 |
#pragma mark - 交给子类们去实现 |
|
70 |
/** 初始化 */ |
|
71 |
- (void)prepare NS_REQUIRES_SUPER; |
|
72 |
/** 摆放子控件frame */ |
|
73 |
- (void)placeSubviews NS_REQUIRES_SUPER; |
|
74 |
/** 当scrollView的contentOffset发生改变的时候调用 */ |
|
75 |
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; |
|
76 |
/** 当scrollView的contentSize发生改变的时候调用 */ |
|
77 |
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; |
|
78 |
/** 当scrollView的拖拽状态发生改变的时候调用 */ |
|
79 |
- (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; |
|
80 |
|
|
81 |
|
|
82 |
#pragma mark - 其他 |
|
83 |
/** 拉拽的百分比(交给子类重写) */ |
|
84 |
@property (assign, nonatomic) CGFloat pullingPercent; |
|
85 |
/** 根据拖拽比例自动切换透明度 */ |
|
86 |
@property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); |
|
87 |
/** 根据拖拽比例自动切换透明度 */ |
|
88 |
@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; |
|
89 |
@end |
|
90 |
|
|
91 |
@interface UILabel(MJRefresh) |
|
92 |
+ (instancetype)label; |
|
93 |
@end |