暫無描述

FKRefreshControl.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // RefreshControl.h
  3. //
  4. // Copyright (c) 2014 YDJ ( https://github.com/ydj/RefreshControl )
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7. // of this software and associated documentation files (the "Software"), to deal
  8. // in the Software without restriction, including without limitation the rights
  9. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. // copies of the Software, and to permit persons to whom the Software is
  11. // furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in
  14. // all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. // THE SOFTWARE.
  23. #import <Foundation/Foundation.h>
  24. #import <UIKit/UIKit.h>
  25. /**
  26. * 当前refreshing状态
  27. */
  28. typedef enum {
  29. RefreshingDirectionNone = 0,
  30. RefreshingDirectionTop = 1 << 0,
  31. RefreshingDirectionBottom = 1 << 1
  32. } RefreshingDirections;
  33. /**
  34. * 指定回调方向
  35. */
  36. typedef enum {
  37. RefreshDirectionTop = 0,
  38. RefreshDirectionBottom
  39. } RefreshDirection;
  40. /**
  41. * 当前refreshing状态
  42. */
  43. //typedef enum {
  44. // FKRefreshingDirectionNone = 0,
  45. // FKRefreshingDirectionTop = 1 << 0,
  46. // FKRefreshingDirectionBottom = 1 << 1
  47. //} FKRefreshingDirections;
  48. //
  49. ///**
  50. // * 指定回调方向
  51. // */
  52. //typedef enum {
  53. // FKRefreshDirectionTop = 0,
  54. // FKRefreshDirectionBottom
  55. //} FKRefreshDirection;
  56. @protocol RefreshControlDelegate;
  57. /**
  58. * 下拉刷新-上拉加载更多
  59. */
  60. @interface FKRefreshControl : NSObject
  61. ///当前的状态
  62. @property (nonatomic,assign,readonly)RefreshingDirections refreshingDirection;
  63. @property (nonatomic,readonly)UIScrollView * scrollView;
  64. - (instancetype)initWithScrollView:(UIScrollView *)scrollView delegate:(id<RefreshControlDelegate>)delegate;
  65. ///是否开启下拉刷新,YES-开启 NO-不开启 默认是NO
  66. @property (nonatomic,assign)BOOL topEnabled;
  67. ///是否开启上拉加载更多,YES-开启 NO-不开启 默认是NO
  68. @property (nonatomic,assign)BOOL bottomEnabled;
  69. ///下拉刷新 状态改变的距离 默认65.0
  70. @property (nonatomic,assign)float enableInsetTop;
  71. ///上拉 状态改变的距离 默认65.0
  72. @property (nonatomic,assign)float enableInsetBottom;
  73. // 底部视图往上偏移距离,默认为0
  74. @property (nonatomic,assign)float bottomRefreshOffsetY;
  75. // 下拉是否启动刷新状态(详情页效果,默认YES)
  76. @property (nonatomic,assign)BOOL enableTopEngage;
  77. // 上拉是否启动刷新状态(详情页效果,默认YES)
  78. @property (nonatomic,assign)float enableBottomEngage;
  79. /*
  80. *是否开启自动刷新,下拉到enableInsetTop位置自动刷新
  81. YES-开启,NO-不开启,默认是NO
  82. */
  83. @property (nonatomic,assign)BOOL autoRefreshTop;
  84. /*
  85. * 是否开启自动加载更多,上拉到enableInsetBottom位置自动加载跟多
  86. YES-开启,NO-不开启,默认是NO
  87. */
  88. @property (nonatomic,assign)BOOL autoRefreshBottom;
  89. /**
  90. * 注册Top加载的view,view必须接受RefreshViewDelegate协议,默认是RefreshTopView
  91. * @param topClass 类类型
  92. */
  93. - (void)registerClassForTopView:(Class)topClass;
  94. /**
  95. * 注册Bottom加载的view,view必须接受RefreshViewDelegate协议,默认是RefreshBottomView
  96. * @param bottomClass 类类型
  97. */
  98. - (void)registerClassForBottomView:(Class)bottomClass;
  99. ///开始
  100. - (void)startRefreshingDirection:(RefreshDirection)direction;
  101. ///完成
  102. - (void)finishRefreshingDirection:(RefreshDirection)direction;
  103. @end
  104. /**
  105. * 代理方法
  106. */
  107. @protocol RefreshControlDelegate <NSObject>
  108. @optional
  109. - (void)refreshControl:(FKRefreshControl *)refreshControl didEngageRefreshDirection:(RefreshDirection) direction;
  110. @end