MJRefreshConst.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // 代码地址: https://github.com/CoderMJLee/MJRefresh
  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. #import <UIKit/UIKit.h>
  4. #import <objc/message.h>
  5. // 弱引用
  6. #define MJWeakSelf __weak typeof(self) weakSelf = self;
  7. // 日志输出
  8. #ifdef DEBUG
  9. #define MJRefreshLog(...) NSLog(__VA_ARGS__)
  10. #else
  11. #define MJRefreshLog(...)
  12. #endif
  13. // 过期提醒
  14. #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
  15. // 运行时objc_msgSend
  16. #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__)
  17. #define MJRefreshMsgTarget(target) (__bridge void *)(target)
  18. // RGB颜色
  19. #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
  20. // 文字颜色
  21. #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90)
  22. // 字体大小
  23. #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14]
  24. // 常量
  25. UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset;
  26. UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight;
  27. UIKIT_EXTERN const CGFloat MJRefreshFooterHeight;
  28. UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration;
  29. UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration;
  30. UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset;
  31. UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize;
  32. UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset;
  33. UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState;
  34. UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey;
  35. UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText;
  36. UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText;
  37. UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText;
  38. UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText;
  39. UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText;
  40. UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText;
  41. UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText;
  42. UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText;
  43. UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText;
  44. UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText;
  45. UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText;
  46. UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText;
  47. UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText;
  48. // 状态检查
  49. #define MJRefreshCheckState \
  50. MJRefreshState oldState = self.state; \
  51. if (state == oldState) return; \
  52. [super setState:state];
  53. // 异步主线程执行,不强持有Self
  54. #define MJRefreshDispatchAsyncOnMainQueue(x) \
  55. __weak typeof(self) weakSelf = self; \
  56. dispatch_async(dispatch_get_main_queue(), ^{ \
  57. typeof(weakSelf) self = weakSelf; \
  58. {x} \
  59. });