123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- //
- // LDPageFlowView.h
- // YouHuiProject
- //
- // Created by liuxueli on 2019/2/25.
- // Copyright © 2019 kuxuan. All rights reserved.
- //
- #import <UIKit/UIKit.h>
- #import <UIKit/UIKit.h>
- #import "LDBannerVewi.h"
- @protocol LDPageFlowViewDataSource;
- @protocol LDPageFlowViewDelegate;
- /******************************
-
- 页面滚动的方向分为横向和纵向
-
- Version 1.0:
- 目的:实现类似于选择电影票的效果,并且实现无限/自动轮播
-
- 特点:1.无限轮播;2.自动轮播;3.电影票样式的层次感;4.非当前显示view具有缩放和透明的特效
-
- 问题:考虑到轮播图的数量不会太大,暂时未做重用处理;对设备性能影响不明显,后期版本会考虑添加重用标识模仿tableview的重用
-
- ******************************/
- typedef enum{
- LDPageFlowViewOrientationHorizontal = 0,
- LDPageFlowViewOrientationVertical
- }LDPageFlowViewOrientation;
- @interface LDPageFlowView : UIView<UIScrollViewDelegate>
- /**
- * 默认为横向
- */
- @property (nonatomic,assign) LDPageFlowViewOrientation orientation;
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic,assign) BOOL needsReload;
- /**
- * 总页数
- */
- @property (nonatomic,assign) NSInteger pageCount;
- @property (nonatomic,strong) NSMutableArray *cells;
- @property (nonatomic,assign) NSRange visibleRange;
- /**
- * 如果以后需要支持reuseIdentifier,这边就得使用字典类型了
- */
- @property (nonatomic,strong) NSMutableArray *reusableCells;
- @property (nonatomic,assign) id <LDPageFlowViewDataSource> dataSource;
- @property (nonatomic,assign) id <LDPageFlowViewDelegate> delegate;
- /**
- * 计时器用到的页数
- */
- @property (nonatomic, assign) NSInteger page;
- /**
- * 指示器
- */
- @property (nonatomic,retain) UIPageControl *pageControl;
- /**
- * 非当前页的透明比例
- */
- @property (nonatomic, assign) CGFloat minimumPageAlpha;
- /**
- 左右间距,默认20
- */
- @property (nonatomic, assign) CGFloat leftRightMargin;
- /**
- 上下间距,默认30
- */
- @property (nonatomic, assign) CGFloat topBottomMargin;
- /**
- * 是否开启自动滚动,默认为开启
- */
- @property (nonatomic, assign) BOOL isOpenAutoScroll;
- /**
- * 是否开启无限轮播,默认为开启
- */
- @property (nonatomic, assign) BOOL isCarousel;
- /**
- * 当前是第几页
- */
- @property (nonatomic, assign, readonly) NSInteger currentPageIndex;
- /**
- * 定时器
- */
- @property (nonatomic, weak) NSTimer *timer;
- /**
- * 自动切换视图的时间,默认是5.0
- */
- @property (nonatomic, assign) CGFloat autoTime;
- /**
- * 原始页数
- */
- @property (nonatomic, assign) NSInteger orginPageCount;
- /**
- * 刷新视图
- */
- - (void)reloadData;
- /**
- * 获取可重复使用的Cell
- *
- * @return <#return value description#>
- */
- - (LDBannerVewi *)dequeueReusableCell;
- /**
- * 滚动到指定的页面
- *
- * @param pageNumber <#pageNumber description#>
- */
- - (void)scrollToPage:(NSUInteger)pageNumber;
- /**
- * 开启定时器,废弃
- */
- //- (void)startTimer;
- /**
- * 关闭定时器,关闭自动滚动
- */
- - (void)stopTimer;
- /**
- 调整中间页居中,经常出现滚动卡住一半时调用
- */
- - (void)adjustCenterSubview;
- @end
- @protocol LDPageFlowViewDelegate<NSObject>
- @optional
- /**
- * 当前显示cell的Size(中间页显示大小)
- *
- * @param flowView <#flowView description#>
- *
- * @return <#return value description#>
- */
- - (CGSize)sizeForPageInFlowView:(LDPageFlowView *)flowView;
- /**
- * 滚动到了某一列
- *
- * @param pageNumber <#pageNumber description#>
- * @param flowView <#flowView description#>
- */
- - (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(LDPageFlowView *)flowView;
- /**
- * 点击了第几个cell
- *
- * @param subView 点击的控件
- * @param subIndex 点击控件的index
- *
- * @return <#return value description#>
- */
- - (void)didSelectCell:(LDBannerVewi *)subView withSubViewIndex:(NSInteger)subIndex;
- @end
- @protocol LDPageFlowViewDataSource <NSObject>
- /**
- * 返回显示View的个数
- *
- * @param flowView <#flowView description#>
- *
- * @return <#return value description#>
- */
- - (NSInteger)numberOfPagesInFlowView:(LDPageFlowView *)flowView;
- /**
- * 给某一列设置属性
- *
- * @param flowView <#flowView description#>
- * @param index <#index description#>
- *
- * @return <#return value description#>
- */
- - (LDBannerVewi *)flowView:(LDPageFlowView *)flowView cellForPageAtIndex:(NSInteger)index;
- @end
|