SDRefreshView.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // SDRefreshView.h
  3. // SDRefreshView
  4. //
  5. // Created by aier on 15-2-22.
  6. // Copyright (c) 2015年 GSD. All rights reserved.
  7. //
  8. /**
  9. *******************************************************
  10. * *
  11. * 感谢您的支持, 如果下载的代码在使用过程中出现BUG或者其他问题 *
  12. * 您可以发邮件到gsdios@126.com 或者 到 *
  13. * https://github.com/gsdios?tab=repositories 提交问题 *
  14. * *
  15. *******************************************************
  16. */
  17. #import <UIKit/UIKit.h>
  18. typedef enum {
  19. SDRefreshViewStateWillRefresh,
  20. SDRefreshViewStateRefreshing,
  21. SDRefreshViewStateNormal
  22. } SDRefreshViewState;
  23. #define SDRefreshViewMethodIOS7 ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0)
  24. #define SDRefreshViewObservingkeyPath @"contentOffset"
  25. #define SDKNavigationBarHeight 64
  26. // ---------------------------配置----------------------------------
  27. // 进入刷新状态时的提示文字
  28. #define SDRefreshViewRefreshingStateText @"正在加载最新数据,请稍候"
  29. // 进入即将刷新状态时的提示文字
  30. #define SDRefreshViewWillRefreshStateText @"松开即可加载最新数据"
  31. // ---------------------------配置----------------------------------
  32. @interface SDRefreshView : UIView
  33. @property (nonatomic, copy) void(^beginRefreshingOperation)();
  34. @property (nonatomic, weak) id beginRefreshingTarget;
  35. @property (nonatomic, assign) SEL beginRefreshingAction;
  36. @property (nonatomic, assign) BOOL isEffectedByNavigationController;
  37. + (instancetype)refreshView;
  38. - (void)addToScrollView:(UIScrollView *)scrollView;
  39. - (void)addToScrollView:(UIScrollView *)scrollView isEffectedByNavigationController:(BOOL)effectedByNavigationController;
  40. - (void)addTarget:(id)target refreshAction:(SEL)action;
  41. - (void)endRefreshing;
  42. @property (nonatomic, weak) UIScrollView *scrollView;
  43. @property (nonatomic, assign) SDRefreshViewState refreshState;
  44. @property (nonatomic, copy) NSString *textForNormalState;
  45. // 子类自定义位置使用
  46. @property (nonatomic, assign) UIEdgeInsets scrollViewEdgeInsets;
  47. @property (nonatomic, assign) CGFloat stateIndicatorViewNormalTransformAngle;
  48. @property (nonatomic, assign) CGFloat stateIndicatorViewWillRefreshStateTransformAngle;
  49. // 记录原始contentEdgeInsets
  50. @property (nonatomic, assign) UIEdgeInsets originalEdgeInsets;
  51. // 加载指示器
  52. @property (nonatomic, weak) UIActivityIndicatorView *activityIndicatorView;
  53. @property (nonatomic, assign) BOOL isManuallyRefreshing;
  54. - (UIEdgeInsets)syntheticalEdgeInsetsWithEdgeInsets:(UIEdgeInsets)edgeInsets;
  55. @end