口袋优选

NewPagedFlowView.h 4.4KB

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