宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//
//  HQFlowView.h
//  HQCardFlowView
//
//  Created by Mr_Han on 2018/7/24.
//  Copyright © 2018年 Mr_Han. All rights reserved.
//  CSDN <https://blog.csdn.net/u010960265>
//  GitHub <https://github.com/HanQiGod>
//
 
#import <UIKit/UIKit.h>
#import "HQIndexBannerSubview.h"
#import "HQImagePageControl.h"
#import "XHPageControl.h"
@protocol HQFlowViewDataSource;
@protocol HQFlowViewDelegate;
 
/******************************
 
 页面滚动的方向分为横向和纵向
 
 Version 1.0:
 目的:实现类似于选择电影票的效果,并且实现无限/自动轮播
 
 特点:1.无限轮播;2.自动轮播;3.电影票样式的层次感;4.非当前显示view具有缩放和透明的特效
 
 问题:考虑到轮播图的数量不会太大,暂时未做重用处理;对设备性能影响不明显,后期版本会考虑添加重用标识模仿tableview的重用
 
 ******************************/
 
typedef enum{
    HQFlowViewOrientationHorizontal = 0,
    HQFlowViewOrientationVertical
}HQFlowViewOrientation;
 
@interface HQFlowView : UIView<UIScrollViewDelegate>
 
/**
 *  默认为横向
 */
@property (nonatomic,assign) HQFlowViewOrientation 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 <HQFlowViewDataSource> dataSource;
@property (nonatomic,assign)   id <HQFlowViewDelegate>   delegate;
 
/**
 *  指示器
 */
@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#>
 */
- (HQIndexBannerSubview *)dequeueReusableCell;
 
/**
 *  滚动到指定的页面
 *
 *  @param pageNumber <#pageNumber description#>
 */
- (void)scrollToPage:(NSUInteger)pageNumber;
 
/**
 *  开启定时器,废弃
 */
- (void)startTimer;
 
/**
 *  关闭定时器,关闭自动滚动
 */
- (void)stopTimer;
 
/**
 调整中间页居中,经常出现滚动卡住一半时调用
 */
- (void)adjustCenterSubview;
 
@end
 
 
@protocol  HQFlowViewDelegate<NSObject>
 
@optional
/**
 *  当前显示cell的Size(中间页显示大小)
 *
 *  @param flowView <#flowView description#>
 *
 *  @return <#return value description#>
 */
- (CGSize)sizeForPageInFlowView:(HQFlowView *)flowView;
 
/**
 *  滚动到了某一列
 *
 *  @param pageNumber <#pageNumber description#>
 *  @param flowView   <#flowView description#>
 */
- (void)didScrollToPage:(NSInteger)pageNumber inFlowView:(HQFlowView *)flowView;
 
/**
 *  点击了第几个cell
 *
 *  @param subView 点击的控件
 *  @param subIndex    点击控件的index
 *
 *  @return <#return value description#>
 */
- (void)didSelectCell:(HQIndexBannerSubview *)subView withSubViewIndex:(NSInteger)subIndex;
 
@end
 
 
@protocol HQFlowViewDataSource <NSObject>
 
/**
 *  返回显示View的个数
 *
 *  @param flowView <#flowView description#>
 *
 *  @return <#return value description#>
 */
- (NSInteger)numberOfPagesInFlowView:(HQFlowView *)flowView;
 
/**
 *  给某一列设置属性
 *
 *  @param flowView <#flowView description#>
 *  @param index    <#index description#>
 *
 *  @return <#return value description#>
 */
- (HQIndexBannerSubview *)flowView:(HQFlowView *)flowView cellForPageAtIndex:(NSInteger)index;
 
@end