HHMJRefreshConst.h
2.73 KB
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
// 代码地址: https://github.com/CoderMJLee/MJRefresh
// 代码地址: 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
#import <UIKit/UIKit.h>
#import <objc/message.h>
// 弱引用
#define MJWeakSelf __weak typeof(self) weakSelf = self;
// 日志输出
#ifdef DEBUG
#define HHMJRefreshLog(...) NSLog(__VA_ARGS__)
#else
#define HHMJRefreshLog(...)
#endif
// 过期提醒
#define HHMJRefreshDeprecated(DESCRIPTION) __attribute__((deprecated(DESCRIPTION)))
// 运行时objc_msgSend
#define HHMJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__)
#define HHMJRefreshMsgTarget(target) (__bridge void *)(target)
// RGB颜色
#define HHMJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
// 文字颜色
#define HHMJRefreshLabelTextColor HHMJRefreshColor(90, 90, 90)
// 字体大小
#define HHMJRefreshLabelFont [UIFont boldSystemFontOfSize:14]
// 常量
UIKIT_EXTERN const CGFloat HHMJRefreshLabelLeftInset;
UIKIT_EXTERN const CGFloat HHMJRefreshHeaderHeight;
UIKIT_EXTERN const CGFloat HHMJRefreshFooterHeight;
UIKIT_EXTERN const CGFloat HHMJRefreshFastAnimationDuration;
UIKIT_EXTERN const CGFloat HHMJRefreshSlowAnimationDuration;
UIKIT_EXTERN NSString *const HHMJRefreshKeyPathContentOffset;
UIKIT_EXTERN NSString *const HHMJRefreshKeyPathContentSize;
UIKIT_EXTERN NSString *const HHMJRefreshKeyPathContentInset;
UIKIT_EXTERN NSString *const HHMJRefreshKeyPathPanState;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderLastUpdatedTimeKey;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderIdleText;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderPullingText;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderRefreshingText;
UIKIT_EXTERN NSString *const HHMJRefreshAutoFooterIdleText;
UIKIT_EXTERN NSString *const HHMJRefreshAutoFooterRefreshingText;
UIKIT_EXTERN NSString *const HHMJRefreshAutoFooterNoMoreDataText;
UIKIT_EXTERN NSString *const HHMJRefreshBackFooterIdleText;
UIKIT_EXTERN NSString *const HHMJRefreshBackFooterPullingText;
UIKIT_EXTERN NSString *const HHMJRefreshBackFooterRefreshingText;
UIKIT_EXTERN NSString *const HHMJRefreshBackFooterNoMoreDataText;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderLastTimeText;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderDateTodayText;
UIKIT_EXTERN NSString *const HHMJRefreshHeaderNoneLastDateText;
// 状态检查
#define MJRefreshCheckState \
HHMJRefreshState oldState = self.state; \
if (state == oldState) return; \
[super setState:state];
// 异步主线程执行,不强持有Self
#define MJRefreshDispatchAsyncOnMainQueue(x) \
__weak typeof(self) weakSelf = self; \
dispatch_async(dispatch_get_main_queue(), ^{ \
typeof(weakSelf) self = weakSelf; \
{x} \
});