JLRefreshBasis.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // JLRefresh.h
  3. // JLRefreshDemo
  4. //
  5. // Created by Jack on 2017/3/3.
  6. // Copyright © 2017年 mini1. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "UIScrollView+JLRefresh.h"
  10. #import "UIView+JLExtension.h"
  11. typedef enum {
  12. /**空闲状态*/
  13. JLRefreshStateIdle = 1 << 0,
  14. /**下拉状态*/
  15. JLRefreshStatePulling = 1 << 1,
  16. /**即将刷新,还未松开*/
  17. JLRefreshStateWillRefresh = 1 << 2,
  18. /**刷新状态,松开*/
  19. JLRefreshStateRefreshing = 1 << 3,
  20. /**没有更多数据*/
  21. JLRefreshStateNoMore = 1 << 4
  22. } JLRefreshState;
  23. UIKIT_EXTERN NSTimeInterval const JLRefreshDuration;
  24. UIKIT_EXTERN CGFloat const JLRefreshHeight;
  25. UIKIT_EXTERN NSString *const JLRefreshKeyPathContentOffset;
  26. UIKIT_EXTERN NSString *const JLRefreshKeyPathContentSize;
  27. UIKIT_EXTERN NSString *const JLRefreshKeyPathContentInset;
  28. UIKIT_EXTERN NSString *const JLRefreshKeyPathState;
  29. @class JLRefreshBasis;
  30. @protocol JLRefreshDelegate <NSObject>
  31. - (void)jl_pullRefresh:(JLRefreshBasis *)refresh state:(JLRefreshState)state percentage:(float)percentage;//percentage's range [0,max)
  32. - (void)jl_beginRefresh:(JLRefreshBasis *)refresh;
  33. - (void)jl_endRefresh:(JLRefreshBasis *)refresh;
  34. @end
  35. @interface JLRefreshBasis : UIView
  36. @property (nonatomic,assign) JLRefreshState state;
  37. @property (nonatomic,assign) float pullPercentage;
  38. @property (nonatomic,weak,readonly) UIScrollView *scrollView;
  39. @property (nonatomic,assign,readonly) CGFloat scrollViewOriginInsetTop; ///<header只管Top
  40. @property (nonatomic,assign,readonly) CGFloat scrollViewOriginInsetBottom; ///<footer只管Bottom
  41. @property (nonatomic,strong,readonly) UIPanGestureRecognizer *pan;
  42. @property (nonatomic,weak) id<JLRefreshDelegate> refreshDelegate;
  43. @property (nonatomic,assign) float pullPercentate;
  44. @property (nonatomic,copy) void (^stateChangeBlock)(JLRefreshState state);
  45. @property (nonatomic,copy) void (^offsetBlock)(CGFloat offset);
  46. @property (nonatomic,assign) BOOL clear;
  47. - (NSString *)refreshTitleForState:(JLRefreshState)state;
  48. - (void)endRefresh;
  49. - (void)prepareInterface;
  50. // 需要子类实现
  51. - (void)scrollViewContentSizeDidChange:(NSDictionary<NSKeyValueChangeKey,id> *)change;
  52. - (void)scrollViewContentOffsetDidChange:(NSDictionary<NSKeyValueChangeKey,id> *)change;
  53. - (void)scrollViewPanGestureStateDidChange:(NSDictionary<NSKeyValueChangeKey,id> *)change;
  54. @end