猎豆优选

LDPageFlowView.h 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //
  2. // LDPageFlowView.h
  3. // YouHuiProject
  4. //
  5. // Created by liuxueli on 2019/2/25.
  6. // Copyright © 2019 kuxuan. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import <UIKit/UIKit.h>
  10. #import "LDBannerVewi.h"
  11. @protocol LDPageFlowViewDataSource;
  12. @protocol LDPageFlowViewDelegate;
  13. /******************************
  14. 页面滚动的方向分为横向和纵向
  15. Version 1.0:
  16. 目的:实现类似于选择电影票的效果,并且实现无限/自动轮播
  17. 特点:1.无限轮播;2.自动轮播;3.电影票样式的层次感;4.非当前显示view具有缩放和透明的特效
  18. 问题:考虑到轮播图的数量不会太大,暂时未做重用处理;对设备性能影响不明显,后期版本会考虑添加重用标识模仿tableview的重用
  19. ******************************/
  20. typedef enum{
  21. LDPageFlowViewOrientationHorizontal = 0,
  22. LDPageFlowViewOrientationVertical
  23. }LDPageFlowViewOrientation;
  24. @interface LDPageFlowView : UIView<UIScrollViewDelegate>
  25. /**
  26. * 默认为横向
  27. */
  28. @property (nonatomic,assign) LDPageFlowViewOrientation orientation;
  29. @property (nonatomic, strong) UIScrollView *scrollView;
  30. @property (nonatomic,assign) BOOL needsReload;
  31. /**
  32. * 总页数
  33. */
  34. @property (nonatomic,assign) NSInteger pageCount;
  35. @property (nonatomic,strong) NSMutableArray *cells;
  36. @property (nonatomic,assign) NSRange visibleRange;
  37. /**
  38. * 如果以后需要支持reuseIdentifier,这边就得使用字典类型了
  39. */
  40. @property (nonatomic,strong) NSMutableArray *reusableCells;
  41. @property (nonatomic,assign) id <LDPageFlowViewDataSource> dataSource;
  42. @property (nonatomic,assign) id <LDPageFlowViewDelegate> delegate;
  43. /**
  44. * 计时器用到的页数
  45. */
  46. @property (nonatomic, assign) NSInteger page;
  47. /**
  48. * 指示器
  49. */
  50. @property (nonatomic,retain) UIPageControl *pageControl;
  51. /**
  52. * 非当前页的透明比例
  53. */
  54. @property (nonatomic, assign) CGFloat minimumPageAlpha;
  55. /**
  56. 左右间距,默认20
  57. */
  58. @property (nonatomic, assign) CGFloat leftRightMargin;
  59. /**
  60. 上下间距,默认30
  61. */
  62. @property (nonatomic, assign) CGFloat topBottomMargin;
  63. /**
  64. * 是否开启自动滚动,默认为开启
  65. */
  66. @property (nonatomic, assign) BOOL isOpenAutoScroll;
  67. /**
  68. * 是否开启无限轮播,默认为开启
  69. */
  70. @property (nonatomic, assign) BOOL isCarousel;
  71. /**
  72. * 当前是第几页
  73. */
  74. @property (nonatomic, assign, readonly) NSInteger currentPageIndex;
  75. /**
  76. * 定时器
  77. */
  78. @property (nonatomic, weak) NSTimer *timer;
  79. /**
  80. * 自动切换视图的时间,默认是5.0
  81. */
  82. @property (nonatomic, assign) CGFloat autoTime;
  83. /**
  84. * 原始页数
  85. */
  86. @property (nonatomic, assign) NSInteger orginPageCount;
  87. /**
  88. * 刷新视图
  89. */
  90. - (void)reloadData;
  91. /**
  92. * 获取可重复使用的Cell
  93. *
  94. * @return <#return value description#>
  95. */
  96. - (LDBannerVewi *)dequeueReusableCell;
  97. /**
  98. * 滚动到指定的页面
  99. *
  100. * @param pageNumber <#pageNumber description#>
  101. */
  102. - (void)scrollToPage:(NSUInteger)pageNumber;
  103. /**
  104. * 开启定时器,废弃
  105. */
  106. //- (void)startTimer;
  107. /**
  108. * 关闭定时器,关闭自动滚动
  109. */
  110. - (void)stopTimer;
  111. /**
  112. 调整中间页居中,经常出现滚动卡住一半时调用
  113. */
  114. - (void)adjustCenterSubview;
  115. @end
  116. @protocol LDPageFlowViewDelegate<NSObject>
  117. @optional
  118. /**
  119. * 当前显示cell的Size(中间页显示大小)
  120. *
  121. * @param flowView <#flowView description#>
  122. *
  123. * @return <#return value description#>
  124. */
  125. - (CGSize)sizeForPageInFlowView:(LDPageFlowView *)flowView;
  126. /**
  127. * 滚动到了某一列
  128. *
  129. * @param pageNumber <#pageNumber description#>
  130. * @param flowView <#flowView description#>
  131. */
  132. - (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(LDPageFlowView *)flowView;
  133. /**
  134. * 点击了第几个cell
  135. *
  136. * @param subView 点击的控件
  137. * @param subIndex 点击控件的index
  138. *
  139. * @return <#return value description#>
  140. */
  141. - (void)didSelectCell:(LDBannerVewi *)subView withSubViewIndex:(NSInteger)subIndex;
  142. @end
  143. @protocol LDPageFlowViewDataSource <NSObject>
  144. /**
  145. * 返回显示View的个数
  146. *
  147. * @param flowView <#flowView description#>
  148. *
  149. * @return <#return value description#>
  150. */
  151. - (NSInteger)numberOfPagesInFlowView:(LDPageFlowView *)flowView;
  152. /**
  153. * 给某一列设置属性
  154. *
  155. * @param flowView <#flowView description#>
  156. * @param index <#index description#>
  157. *
  158. * @return <#return value description#>
  159. */
  160. - (LDBannerVewi *)flowView:(LDPageFlowView *)flowView cellForPageAtIndex:(NSInteger)index;
  161. @end