Ei kuvausta

SDCycleScrollView.m 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. //
  2. // SDCycleScrollView.m
  3. // SDCycleScrollView
  4. //
  5. // Created by aier on 15-3-22.
  6. // Copyright (c) 2015年 GSD. All rights reserved.
  7. //
  8. /*
  9. *********************************************************************************
  10. *
  11. * 🌟🌟🌟 新建SDCycleScrollView交流QQ群:185534916 🌟🌟🌟
  12. *
  13. * 在您使用此自动轮播库的过程中如果出现bug请及时以以下任意一种方式联系我们,我们会及时修复bug并
  14. * 帮您解决问题。
  15. * 新浪微博:GSD_iOS
  16. * Email : gsdios@126.com
  17. * GitHub: https://github.com/gsdios
  18. *
  19. * 另(我的自动布局库SDAutoLayout):
  20. * 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于
  21. * 做最简单易用的AutoLayout库。
  22. * 视频教程:http://www.letv.com/ptv/vplay/24038772.html
  23. * 用法示例:https://github.com/gsdios/SDAutoLayout/blob/master/README.md
  24. * GitHub:https://github.com/gsdios/SDAutoLayout
  25. *********************************************************************************
  26. */
  27. #import "SDCycleScrollView.h"
  28. #import "SDCollectionViewCell.h"
  29. #import "UIView+SDExtension.h"
  30. #import "TAPageControl.h"
  31. #import "UIImageView+WebCache.h"
  32. #import "SDImageCache.h"
  33. #import "SDWebImageManager.h"
  34. #define kCycleScrollViewInitialPageControlDotSize CGSizeMake(10, 10)
  35. NSString * const ID = @"cycleCell";
  36. @interface SDCycleScrollView () <UICollectionViewDataSource, UICollectionViewDelegate>
  37. @property (nonatomic, weak) UICollectionView *mainView; // 显示图片的collectionView
  38. @property (nonatomic, weak) UICollectionViewFlowLayout *flowLayout;
  39. @property (nonatomic, strong) NSArray *imagePathsGroup;
  40. @property (nonatomic, weak) NSTimer *timer;
  41. @property (nonatomic, assign) NSInteger totalItemsCount;
  42. @property (nonatomic, weak) UIControl *pageControl;
  43. @property (nonatomic, strong) UIImageView *backgroundImageView; // 当imageURLs为空时的背景图
  44. @end
  45. @implementation SDCycleScrollView
  46. - (instancetype)initWithFrame:(CGRect)frame
  47. {
  48. if (self = [super initWithFrame:frame]) {
  49. [self initialization];
  50. [self setupMainView];
  51. }
  52. return self;
  53. }
  54. - (void)awakeFromNib
  55. {
  56. [super awakeFromNib];
  57. [self initialization];
  58. [self setupMainView];
  59. }
  60. - (void)initialization
  61. {
  62. _pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
  63. _autoScrollTimeInterval = 7.0;
  64. _titleLabelTextColor = [UIColor whiteColor];
  65. _titleLabelTextFont= [UIFont systemFontOfSize:14];
  66. _titleLabelBackgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
  67. _titleLabelHeight = 30;
  68. _autoScroll = YES;
  69. _infiniteLoop = YES;
  70. _showPageControl = YES;
  71. _pageControlDotSize = kCycleScrollViewInitialPageControlDotSize;
  72. _pageControlBottomOffset = 0;
  73. _pageControlRightOffset = 0;
  74. _pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
  75. _hidesForSinglePage = YES;
  76. _currentPageDotColor = [UIColor whiteColor];
  77. _pageDotColor = [UIColor lightGrayColor];
  78. _bannerImageViewContentMode = UIViewContentModeScaleToFill;
  79. self.backgroundColor = [UIColor lightGrayColor];
  80. }
  81. + (instancetype)cycleScrollViewWithFrame:(CGRect)frame imageNamesGroup:(NSArray *)imageNamesGroup
  82. {
  83. SDCycleScrollView *cycleScrollView = [[self alloc] initWithFrame:frame];
  84. cycleScrollView.localizationImageNamesGroup = [NSMutableArray arrayWithArray:imageNamesGroup];
  85. return cycleScrollView;
  86. }
  87. + (instancetype)cycleScrollViewWithFrame:(CGRect)frame shouldInfiniteLoop:(BOOL)infiniteLoop imageNamesGroup:(NSArray *)imageNamesGroup
  88. {
  89. SDCycleScrollView *cycleScrollView = [[self alloc] initWithFrame:frame];
  90. cycleScrollView.infiniteLoop = infiniteLoop;
  91. cycleScrollView.localizationImageNamesGroup = [NSMutableArray arrayWithArray:imageNamesGroup];
  92. return cycleScrollView;
  93. }
  94. + (instancetype)cycleScrollViewWithFrame:(CGRect)frame imageURLStringsGroup:(NSArray *)imageURLsGroup
  95. {
  96. SDCycleScrollView *cycleScrollView = [[self alloc] initWithFrame:frame];
  97. cycleScrollView.imageURLStringsGroup = [NSMutableArray arrayWithArray:imageURLsGroup];
  98. return cycleScrollView;
  99. }
  100. + (instancetype)cycleScrollViewWithFrame:(CGRect)frame delegate:(id<SDCycleScrollViewDelegate>)delegate placeholderImage:(UIImage *)placeholderImage
  101. {
  102. SDCycleScrollView *cycleScrollView = [[self alloc] initWithFrame:frame];
  103. cycleScrollView.delegate = delegate;
  104. cycleScrollView.placeholderImage = placeholderImage;
  105. return cycleScrollView;
  106. }
  107. // 设置显示图片的collectionView
  108. - (void)setupMainView
  109. {
  110. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  111. flowLayout.minimumLineSpacing = 0;
  112. flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  113. _flowLayout = flowLayout;
  114. UICollectionView *mainView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout];
  115. mainView.backgroundColor = [UIColor clearColor];
  116. mainView.pagingEnabled = YES;
  117. mainView.showsHorizontalScrollIndicator = NO;
  118. mainView.showsVerticalScrollIndicator = NO;
  119. [mainView registerClass:[SDCollectionViewCell class] forCellWithReuseIdentifier:ID];
  120. mainView.dataSource = self;
  121. mainView.delegate = self;
  122. mainView.scrollsToTop = NO;
  123. [self addSubview:mainView];
  124. _mainView = mainView;
  125. }
  126. #pragma mark - properties
  127. - (void)setPlaceholderImage:(UIImage *)placeholderImage
  128. {
  129. _placeholderImage = placeholderImage;
  130. if (!self.backgroundImageView) {
  131. UIImageView *bgImageView = [UIImageView new];
  132. bgImageView.contentMode = UIViewContentModeScaleAspectFit;
  133. [self insertSubview:bgImageView belowSubview:self.mainView];
  134. self.backgroundImageView = bgImageView;
  135. }
  136. self.backgroundImageView.image = placeholderImage;
  137. }
  138. - (void)setPageControlDotSize:(CGSize)pageControlDotSize
  139. {
  140. _pageControlDotSize = pageControlDotSize;
  141. [self setupPageControl];
  142. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  143. TAPageControl *pageContol = (TAPageControl *)_pageControl;
  144. pageContol.dotSize = pageControlDotSize;
  145. }
  146. }
  147. - (void)setShowPageControl:(BOOL)showPageControl
  148. {
  149. _showPageControl = showPageControl;
  150. _pageControl.hidden = !showPageControl;
  151. }
  152. - (void)setCurrentPageDotColor:(UIColor *)currentPageDotColor
  153. {
  154. _currentPageDotColor = currentPageDotColor;
  155. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  156. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  157. pageControl.dotColor = currentPageDotColor;
  158. } else {
  159. UIPageControl *pageControl = (UIPageControl *)_pageControl;
  160. pageControl.currentPageIndicatorTintColor = currentPageDotColor;
  161. }
  162. }
  163. - (void)setPageDotColor:(UIColor *)pageDotColor
  164. {
  165. _pageDotColor = pageDotColor;
  166. if ([self.pageControl isKindOfClass:[UIPageControl class]]) {
  167. UIPageControl *pageControl = (UIPageControl *)_pageControl;
  168. pageControl.pageIndicatorTintColor = pageDotColor;
  169. }
  170. }
  171. - (void)setCurrentPageDotImage:(UIImage *)currentPageDotImage
  172. {
  173. _currentPageDotImage = currentPageDotImage;
  174. if (self.pageControlStyle != SDCycleScrollViewPageContolStyleAnimated) {
  175. self.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
  176. }
  177. [self setCustomPageControlDotImage:currentPageDotImage isCurrentPageDot:YES];
  178. }
  179. - (void)setPageDotImage:(UIImage *)pageDotImage
  180. {
  181. _pageDotImage = pageDotImage;
  182. if (self.pageControlStyle != SDCycleScrollViewPageContolStyleAnimated) {
  183. self.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
  184. }
  185. [self setCustomPageControlDotImage:pageDotImage isCurrentPageDot:NO];
  186. }
  187. - (void)setCustomPageControlDotImage:(UIImage *)image isCurrentPageDot:(BOOL)isCurrentPageDot
  188. {
  189. if (!image || !self.pageControl) return;
  190. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  191. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  192. if (isCurrentPageDot) {
  193. pageControl.currentDotImage = image;
  194. } else {
  195. pageControl.dotImage = image;
  196. }
  197. }
  198. }
  199. - (void)setInfiniteLoop:(BOOL)infiniteLoop
  200. {
  201. _infiniteLoop = infiniteLoop;
  202. if (self.imagePathsGroup.count) {
  203. self.imagePathsGroup = self.imagePathsGroup;
  204. }
  205. }
  206. -(void)setAutoScroll:(BOOL)autoScroll{
  207. _autoScroll = autoScroll;
  208. [self invalidateTimer];
  209. if (_autoScroll) {
  210. [self setupTimer];
  211. }
  212. }
  213. - (void)setScrollDirection:(UICollectionViewScrollDirection)scrollDirection
  214. {
  215. _scrollDirection = scrollDirection;
  216. _flowLayout.scrollDirection = scrollDirection;
  217. }
  218. - (void)setAutoScrollTimeInterval:(CGFloat)autoScrollTimeInterval
  219. {
  220. _autoScrollTimeInterval = autoScrollTimeInterval;
  221. [self setAutoScroll:self.autoScroll];
  222. }
  223. - (void)setPageControlStyle:(SDCycleScrollViewPageContolStyle)pageControlStyle
  224. {
  225. _pageControlStyle = pageControlStyle;
  226. [self setupPageControl];
  227. }
  228. - (void)setImagePathsGroup:(NSArray *)imagePathsGroup
  229. {
  230. [self invalidateTimer];
  231. _imagePathsGroup = imagePathsGroup;
  232. _totalItemsCount = self.infiniteLoop ? self.imagePathsGroup.count * 100 : self.imagePathsGroup.count;
  233. if (imagePathsGroup.count != 1) {
  234. self.mainView.scrollEnabled = YES;
  235. [self setAutoScroll:self.autoScroll];
  236. } else {
  237. self.mainView.scrollEnabled = NO;
  238. }
  239. [self setupPageControl];
  240. [self.mainView reloadData];
  241. }
  242. - (void)setImageURLStringsGroup:(NSArray *)imageURLStringsGroup
  243. {
  244. _imageURLStringsGroup = imageURLStringsGroup;
  245. NSMutableArray *temp = [NSMutableArray new];
  246. [_imageURLStringsGroup enumerateObjectsUsingBlock:^(NSString * obj, NSUInteger idx, BOOL * stop) {
  247. NSString *urlString;
  248. if ([obj isKindOfClass:[NSString class]]) {
  249. urlString = obj;
  250. } else if ([obj isKindOfClass:[NSURL class]]) {
  251. NSURL *url = (NSURL *)obj;
  252. urlString = [url absoluteString];
  253. }
  254. if (urlString) {
  255. [temp addObject:urlString];
  256. }
  257. }];
  258. self.imagePathsGroup = [temp copy];
  259. }
  260. - (void)setLocalizationImageNamesGroup:(NSArray *)localizationImageNamesGroup
  261. {
  262. _localizationImageNamesGroup = localizationImageNamesGroup;
  263. self.imagePathsGroup = [localizationImageNamesGroup copy];
  264. }
  265. - (void)setTitlesGroup:(NSArray *)titlesGroup
  266. {
  267. _titlesGroup = titlesGroup;
  268. if (self.onlyDisplayText) {
  269. NSMutableArray *temp = [NSMutableArray new];
  270. for (int i = 0; i < _titlesGroup.count; i++) {
  271. [temp addObject:@""];
  272. }
  273. self.backgroundColor = [UIColor clearColor];
  274. self.imageURLStringsGroup = [temp copy];
  275. }
  276. }
  277. #pragma mark - actions
  278. - (void)setupTimer
  279. {
  280. NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:self.autoScrollTimeInterval target:self selector:@selector(automaticScroll) userInfo:nil repeats:YES];
  281. _timer = timer;
  282. [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
  283. }
  284. - (void)invalidateTimer
  285. {
  286. [_timer invalidate];
  287. _timer = nil;
  288. }
  289. - (void)setupPageControl
  290. {
  291. if (_pageControl) [_pageControl removeFromSuperview]; // 重新加载数据时调整
  292. if (self.imagePathsGroup.count == 0 || self.onlyDisplayText) return;
  293. if ((self.imagePathsGroup.count == 1) && self.hidesForSinglePage) return;
  294. int indexOnPageControl = [self pageControlIndexWithCurrentCellIndex:[self currentIndex]];
  295. switch (self.pageControlStyle) {
  296. case SDCycleScrollViewPageContolStyleAnimated:
  297. {
  298. TAPageControl *pageControl = [[TAPageControl alloc] init];
  299. pageControl.numberOfPages = self.imagePathsGroup.count;
  300. pageControl.dotColor = self.currentPageDotColor;
  301. pageControl.userInteractionEnabled = NO;
  302. pageControl.currentPage = indexOnPageControl;
  303. [self addSubview:pageControl];
  304. _pageControl = pageControl;
  305. }
  306. break;
  307. case SDCycleScrollViewPageContolStyleClassic:
  308. {
  309. UIPageControl *pageControl = [[UIPageControl alloc] init];
  310. pageControl.numberOfPages = self.imagePathsGroup.count;
  311. pageControl.currentPageIndicatorTintColor = self.currentPageDotColor;
  312. pageControl.pageIndicatorTintColor = self.pageDotColor;
  313. pageControl.userInteractionEnabled = NO;
  314. pageControl.currentPage = indexOnPageControl;
  315. [self addSubview:pageControl];
  316. _pageControl = pageControl;
  317. }
  318. break;
  319. default:
  320. break;
  321. }
  322. // 重设pagecontroldot图片
  323. if (self.currentPageDotImage) {
  324. self.currentPageDotImage = self.currentPageDotImage;
  325. }
  326. if (self.pageDotImage) {
  327. self.pageDotImage = self.pageDotImage;
  328. }
  329. }
  330. - (void)automaticScroll
  331. {
  332. if (0 == _totalItemsCount) return;
  333. int currentIndex = [self currentIndex];
  334. int targetIndex = currentIndex + 1;
  335. [self scrollToIndex:targetIndex];
  336. }
  337. - (void)scrollToIndex:(int)targetIndex
  338. {
  339. if (targetIndex >= _totalItemsCount) {
  340. if (self.infiniteLoop) {
  341. targetIndex = _totalItemsCount * 0.5;
  342. [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
  343. }
  344. return;
  345. }
  346. [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:YES];
  347. }
  348. - (int)currentIndex
  349. {
  350. if (_mainView.sd_width == 0 || _mainView.sd_height == 0) {
  351. return 0;
  352. }
  353. int index = 0;
  354. if (_flowLayout.scrollDirection == UICollectionViewScrollDirectionHorizontal) {
  355. index = (_mainView.contentOffset.x + _flowLayout.itemSize.width * 0.5) / _flowLayout.itemSize.width;
  356. } else {
  357. index = (_mainView.contentOffset.y + _flowLayout.itemSize.height * 0.5) / _flowLayout.itemSize.height;
  358. }
  359. return MAX(0, index);
  360. }
  361. - (int)pageControlIndexWithCurrentCellIndex:(NSInteger)index
  362. {
  363. return (int)index % self.imagePathsGroup.count;
  364. }
  365. - (void)clearCache
  366. {
  367. [[self class] clearImagesCache];
  368. }
  369. + (void)clearImagesCache
  370. {
  371. // [[[SDWebImageManager sharedManager] imageCache] clearDisk];
  372. }
  373. #pragma mark - life circles
  374. - (void)layoutSubviews
  375. {
  376. [super layoutSubviews];
  377. _flowLayout.itemSize = self.frame.size;
  378. _mainView.frame = self.bounds;
  379. if (_mainView.contentOffset.x == 0 && _totalItemsCount) {
  380. int targetIndex = 0;
  381. if (self.infiniteLoop) {
  382. targetIndex = _totalItemsCount * 0.5;
  383. }else{
  384. targetIndex = 0;
  385. }
  386. [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
  387. }
  388. CGSize size = CGSizeZero;
  389. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  390. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  391. if (!(self.pageDotImage && self.currentPageDotImage && CGSizeEqualToSize(kCycleScrollViewInitialPageControlDotSize, self.pageControlDotSize))) {
  392. pageControl.dotSize = self.pageControlDotSize;
  393. }
  394. size = [pageControl sizeForNumberOfPages:self.imagePathsGroup.count];
  395. } else {
  396. size = CGSizeMake(self.imagePathsGroup.count * self.pageControlDotSize.width * 1.5, self.pageControlDotSize.height);
  397. }
  398. CGFloat x = (self.sd_width - size.width) * 0.5;
  399. if (self.pageControlAliment == SDCycleScrollViewPageContolAlimentRight) {
  400. x = self.mainView.sd_width - size.width - 10;
  401. }
  402. CGFloat y = self.mainView.sd_height - size.height - 10;
  403. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  404. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  405. [pageControl sizeToFit];
  406. }
  407. CGRect pageControlFrame = CGRectMake(x, y, size.width, size.height);
  408. pageControlFrame.origin.y -= self.pageControlBottomOffset;
  409. pageControlFrame.origin.x -= self.pageControlRightOffset;
  410. self.pageControl.frame = pageControlFrame;
  411. self.pageControl.hidden = !_showPageControl;
  412. if (self.backgroundImageView) {
  413. self.backgroundImageView.frame = self.bounds;
  414. }
  415. }
  416. //解决当父View释放时,当前视图因为被Timer强引用而不能释放的问题
  417. - (void)willMoveToSuperview:(UIView *)newSuperview
  418. {
  419. if (!newSuperview) {
  420. [self invalidateTimer];
  421. }
  422. }
  423. //解决当timer释放后 回调scrollViewDidScroll时访问野指针导致崩溃
  424. - (void)dealloc {
  425. _mainView.delegate = nil;
  426. _mainView.dataSource = nil;
  427. }
  428. #pragma mark - public actions
  429. - (void)adjustWhenControllerViewWillAppera
  430. {
  431. long targetIndex = [self currentIndex];
  432. if (targetIndex < _totalItemsCount) {
  433. [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
  434. }
  435. }
  436. #pragma mark - UICollectionViewDataSource
  437. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  438. {
  439. return _totalItemsCount;
  440. }
  441. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  442. {
  443. SDCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  444. long itemIndex = [self pageControlIndexWithCurrentCellIndex:indexPath.item];
  445. NSString *imagePath = self.imagePathsGroup[itemIndex];
  446. if (!self.onlyDisplayText && [imagePath isKindOfClass:[NSString class]]) {
  447. if ([imagePath hasPrefix:@"http"]) {
  448. [cell.imageView sd_setImageWithURL:[NSURL URLWithString:imagePath] placeholderImage:self.placeholderImage];
  449. } else {
  450. UIImage *image = [UIImage imageNamed:imagePath];
  451. if (!image) {
  452. [UIImage imageWithContentsOfFile:imagePath];
  453. }
  454. cell.imageView.image = image;
  455. }
  456. } else if (!self.onlyDisplayText && [imagePath isKindOfClass:[UIImage class]]) {
  457. cell.imageView.image = (UIImage *)imagePath;
  458. }
  459. if (_titlesGroup.count && itemIndex < _titlesGroup.count) {
  460. cell.title = _titlesGroup[itemIndex];
  461. }
  462. if (!cell.hasConfigured) {
  463. cell.titleLabelBackgroundColor = self.titleLabelBackgroundColor;
  464. cell.titleLabelHeight = self.titleLabelHeight;
  465. cell.titleLabelTextColor = self.titleLabelTextColor;
  466. cell.titleLabelTextFont = self.titleLabelTextFont;
  467. cell.hasConfigured = YES;
  468. cell.imageView.contentMode = self.bannerImageViewContentMode;
  469. cell.clipsToBounds = YES;
  470. cell.onlyDisplayText = self.onlyDisplayText;
  471. }
  472. return cell;
  473. }
  474. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  475. {
  476. if ([self.delegate respondsToSelector:@selector(cycleScrollView:didSelectItemAtIndex:)]) {
  477. [self.delegate cycleScrollView:self didSelectItemAtIndex:[self pageControlIndexWithCurrentCellIndex:indexPath.item]];
  478. }
  479. if (self.clickItemOperationBlock) {
  480. self.clickItemOperationBlock([self pageControlIndexWithCurrentCellIndex:indexPath.item]);
  481. }
  482. }
  483. #pragma mark - UIScrollViewDelegate
  484. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  485. {
  486. if (!self.imagePathsGroup.count) return; // 解决清除timer时偶尔会出现的问题
  487. int itemIndex = [self currentIndex];
  488. int indexOnPageControl = [self pageControlIndexWithCurrentCellIndex:itemIndex];
  489. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  490. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  491. pageControl.currentPage = indexOnPageControl;
  492. } else {
  493. UIPageControl *pageControl = (UIPageControl *)_pageControl;
  494. pageControl.currentPage = indexOnPageControl;
  495. }
  496. }
  497. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  498. {
  499. if (self.autoScroll) {
  500. [self invalidateTimer];
  501. }
  502. }
  503. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
  504. {
  505. if (self.autoScroll) {
  506. [self setupTimer];
  507. }
  508. }
  509. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  510. {
  511. [self scrollViewDidEndScrollingAnimation:self.mainView];
  512. }
  513. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
  514. {
  515. if (!self.imagePathsGroup.count) return; // 解决清除timer时偶尔会出现的问题
  516. int itemIndex = [self currentIndex];
  517. int indexOnPageControl = [self pageControlIndexWithCurrentCellIndex:itemIndex];
  518. if ([self.delegate respondsToSelector:@selector(cycleScrollView:didScrollToIndex:)]) {
  519. [self.delegate cycleScrollView:self didScrollToIndex:indexOnPageControl];
  520. } else if (self.itemDidScrollOperationBlock) {
  521. self.itemDidScrollOperationBlock(indexOnPageControl);
  522. }
  523. }
  524. -(void)ayaduLZs7:(UIInputView*) ayaduLZs7 akUAePYR:(UIColor*) akUAePYR a1niVNtT:(UIVisualEffectView*) a1niVNtT aSKVsXvwZ:(UIImageView*) aSKVsXvwZ a8fnMkO:(UISwitch*) a8fnMkO aQbBw1jCXs2:(UIMotionEffect*) aQbBw1jCXs2 adu2GjxHZ5:(UITableView*) adu2GjxHZ5 axZK1kE6CF:(UIImage*) axZK1kE6CF a36fn9x4o:(UIUserInterfaceIdiom*) a36fn9x4o aZsP0iEwrcS:(UIFontWeight*) aZsP0iEwrcS aF9iyLVu:(UIMotionEffect*) aF9iyLVu acECG7qmHVB:(UIMenuItem*) acECG7qmHVB ahiL08qkJz:(UIButton*) ahiL08qkJz a5Azelp1G:(UIScreen*) a5Azelp1G aNXIzl:(UIVisualEffectView*) aNXIzl abTOC2p:(UIButton*) abTOC2p alsjo3:(UIKeyCommand*) alsjo3 {
  525. NSLog(@"MGhkAm1WKxBdFP0YTOj");
  526. NSLog(@"DgpxPtGoU1");
  527. NSLog(@"6sQvnSlCWZkfGrqV5euHmPRh3");
  528. NSLog(@"zxuCDG53RLt06hsFiqnfjTwZ9MB1IkaV");
  529. NSLog(@"408bmRispweNVB");
  530. NSLog(@"43Org7TuU2vKF");
  531. NSLog(@"qVuhTOJk7UvE4wFpneoPm29YM5XI");
  532. NSLog(@"Xqmo2R7teklFCUV");
  533. NSLog(@"rP8twgCE1TXI9uhV");
  534. NSLog(@"xPmFrV9pBZ7g5n3jUw2AdSWlX");
  535. NSLog(@"BE71NZ6DzulTM3HSQ4rLKekfGJApYyw05j");
  536. NSLog(@"4JaQT6qHeXisIDGBKrP5nogWwMuE3UmSN7c");
  537. NSLog(@"L8aOqMyNzBtxZfVweA3jEGDbsdlRY");
  538. NSLog(@"0awMGqTiUA1NzvDRb4ILHOZYp98hkVxtj6B");
  539. NSLog(@"j1BaObcGCLrlpDhx9Uuz8y");
  540. }
  541. -(void)awaN9YM6mHf:(UIControlEvents*) awaN9YM6mHf agcuYIN:(UIImageView*) agcuYIN azFBRn:(UIImage*) azFBRn aUnZYI:(UIControl*) aUnZYI aj8F1OKquzP:(UIFont*) aj8F1OKquzP a8qup:(UIImageView*) a8qup aR3MJ5:(UIImage*) aR3MJ5 ayKHPdGtm:(UIFontWeight*) ayKHPdGtm aiqJNX64xIF:(UIViewController*) aiqJNX64xIF akyB8N2K1hE:(UIEvent*) akyB8N2K1hE axye6fFd2:(UIAlertView*) axye6fFd2 apEfVgcUMN:(UIBarButtonItem*) apEfVgcUMN {
  542. NSLog(@"pjB0ynYsku");
  543. NSLog(@"B6iIR7egKvL8yOj");
  544. NSLog(@"IYdgchzAj6lB0UvNpSXxTFWekHy9aRniDf");
  545. NSLog(@"XtWhnU7MmOD31KBdyzp2A");
  546. NSLog(@"KjampIrs3bNYUtwxMFJ4y6oQivRHuzdfZB");
  547. NSLog(@"QomIVhq29kXd1Ogepxas3");
  548. NSLog(@"dWzYDvHMpNSxUR9khQ3aIGoFZj8by70KL4Jn");
  549. NSLog(@"JDvXYI0OHxrhfuVSa31o");
  550. NSLog(@"0G6MsHiUTjwXOoFehf25xDERaJSy3");
  551. NSLog(@"bWN76IqoH9rMhK");
  552. NSLog(@"IrHsxXzROka4CqV8tSWlY93KNhM");
  553. NSLog(@"PTBrpeDsOC9jUc");
  554. NSLog(@"DXKkNAe9pLM2o3zY7fmHw4Oj");
  555. }
  556. -(void)azrEd0X:(UIDocument*) azrEd0X a6nu0b:(UIImage*) a6nu0b aIC1H4B:(UIMenuItem*) aIC1H4B aIPU7Ka:(UIBarButtonItem*) aIPU7Ka ah6eX:(UIDocument*) ah6eX aUHyM:(UIImage*) aUHyM aLBTVEQ:(UIAlertView*) aLBTVEQ asz49XeTV:(UIBarButtonItem*) asz49XeTV avAMsyE:(UIDevice*) avAMsyE aQBmE5S7POn:(UIView*) aQBmE5S7POn aDSdR7EN:(UIDevice*) aDSdR7EN axVANmj:(UIMotionEffect*) axVANmj ayuSh6p:(UIFont*) ayuSh6p a64WaZ:(UIBarButtonItem*) a64WaZ aASuXcbC:(UIButton*) aASuXcbC ay6TnMBL:(UIVisualEffectView*) ay6TnMBL akxvRzTQt:(UIViewController*) akxvRzTQt a3QEx9lH:(UIControl*) a3QEx9lH alG2rtaPsN:(UIUserInterfaceIdiom*) alG2rtaPsN aU6B0:(UISearchBar*) aU6B0 {
  557. NSLog(@"GwaSBoMTmskPgVJ7pvO");
  558. NSLog(@"7p2ktPewiXYO5CaIDK6nA3SFZshLoQ");
  559. NSLog(@"78JhYo5mCFU3NB6v2sbdjQRpAELfrweGiISx");
  560. NSLog(@"8Q42fRN6LpT5t0PKMcBVCeuiI");
  561. NSLog(@"kP9v2myNA0EZGg7Lnt3XJjHCfl1KiTM5pIz6");
  562. NSLog(@"mPncKDNHeIY8vqw0F9EjuX4CgxiUAWyfo");
  563. NSLog(@"3TzFh1oGmZtQf2VU4sLX5YD9AyHnKe");
  564. NSLog(@"gRuLDQmepVNh09F");
  565. NSLog(@"ADFabug8TYQKv6slRd13iBVEUZXpHyLOe");
  566. NSLog(@"hLUoraFSdJpcsOtVyiDfW59ve8ZngujYMw");
  567. }
  568. -(void)aQCeNr:(UIMotionEffect*) aQCeNr aW8MVG:(UIFontWeight*) aW8MVG ayb2R0EXHm:(UIAlertView*) ayb2R0EXHm aOhVXYeZ8C:(UIInputView*) aOhVXYeZ8C aHVvwAGo:(UIInputView*) aHVvwAGo {
  569. NSLog(@"FZ9It0WoEO32QJiD7");
  570. NSLog(@"o2J50yscVlURMrEXdeqS6zxZ7w4FY1DTvAfWG9hi");
  571. NSLog(@"iFO0EdkRQAjzsvoD2S");
  572. NSLog(@"hksr8qWpTYEBzICgtXmUPHdniNxJGR2D70");
  573. NSLog(@"S9NKV46FcEw2TYMtgDUXyZu5Oe70HhIkvPGpqox");
  574. NSLog(@"YLkPd0WEgSxypOwKh9aUVunQD56q");
  575. NSLog(@"qPJXob9w4f7HnE0MkcCGld");
  576. NSLog(@"taVWFli12T6kL5bp");
  577. NSLog(@"BUE2Rv9YMgW3hpiDGzwH6XN5mKCAodTykcQFtnsb");
  578. NSLog(@"V1NgndbyHMFAD");
  579. NSLog(@"qbWIURu4t9aH");
  580. NSLog(@"Py5lpjdFiutN2f0");
  581. NSLog(@"wRtj4VZvO2ALhk1MWXIE50KDPGz");
  582. NSLog(@"5RemqblrfpCSKa749wM");
  583. NSLog(@"ayJIK9BO7YGn3bRWlSv");
  584. NSLog(@"vj8NEophQM7dl0ZPksGFt5JqA3TCYKBru");
  585. NSLog(@"N0DWSd2InpL5ATwkjfCrHB8oXZJbVOvFaih");
  586. }
  587. -(void)arCHuZ9GmA2:(UIBarButtonItem*) arCHuZ9GmA2 aSTdyJ:(UIViewController*) aSTdyJ adJ14f5i:(UIActivity*) adJ14f5i adXaP:(UIBarButtonItem*) adXaP aJs72hwy:(UIControl*) aJs72hwy audRDevBojk:(UIAlertView*) audRDevBojk aLGpJZ:(UIFontWeight*) aLGpJZ aQ8FY:(UIImageView*) aQ8FY {
  588. NSLog(@"L0B7OvngkCdrwfUpVS63Xm5uAEbyacZ4J");
  589. NSLog(@"W4vioEphyljGMI8Crm0DX6quR");
  590. NSLog(@"OShAxDJwgvq26uy1QEVFiRzd9pe4");
  591. NSLog(@"8pvuOKxMca6YSrgqECwlD23mG");
  592. NSLog(@"hmqna7ZLpzEKw18rXoAQ0dJGxfD");
  593. NSLog(@"84zK0QtMqBZkcgVWH5eTG6YoymsuXfFpx1OPr9bJ");
  594. NSLog(@"J7IqsdFHThX2RoLb3GfWB5enmCrwi6");
  595. NSLog(@"xmLHypubdPtFcNlkX8Wz9");
  596. NSLog(@"MdoZixQSUgLOkr2p6GBnWXhDcuJPV10bFYajwN");
  597. NSLog(@"q5B2bHPYGz71frik94vdhQ0Egj");
  598. NSLog(@"2EebnDiKIrJoBT1pRqSf");
  599. }
  600. -(void)aUpKz2cwG:(UIEdgeInsets*) aUpKz2cwG axiN4V8:(UIRegion*) axiN4V8 aVQzoZpEJuD:(UIEvent*) aVQzoZpEJuD aGDIOj:(UIScreen*) aGDIOj apavXE5G:(UIView*) apavXE5G avOVyU0tw:(UIApplication*) avOVyU0tw ae9L67l:(UIColor*) ae9L67l aaJjY28TCci:(UIFont*) aaJjY28TCci acYCTSt8l:(UIScreen*) acYCTSt8l aEIh2:(UIKeyCommand*) aEIh2 afv0dH:(UIDocument*) afv0dH aGki7fw:(UIImage*) aGki7fw a9XU0LJW2:(UISearchBar*) a9XU0LJW2 aB8aC:(UIKeyCommand*) aB8aC as4RpqP:(UIWindow*) as4RpqP aToS5:(UIMotionEffect*) aToS5 aPepUVvR:(UIFont*) aPepUVvR a9hVqZsMI:(UIButton*) a9hVqZsMI auA3gKqGxDv:(UILabel*) auA3gKqGxDv {
  601. NSLog(@"pYFjJeS0hvBn41moHT85fkPMAlOQcyqdN2RKrLCI");
  602. NSLog(@"q2bHfJ6emiaZMws1vO7hXj3");
  603. NSLog(@"i24Q0tZAWIVUwxE7");
  604. NSLog(@"UBOiWZ8yPo2jKbAILaJGpD1TnxQqv");
  605. NSLog(@"PjSI4Tfb2aNersXB7l9U8ZtJuWiKnFvVHdCo");
  606. NSLog(@"TizZgFos0RfEm5XA6YKbnjc");
  607. NSLog(@"3rcjSMHAefxYEl71zgCoZRGXsm");
  608. NSLog(@"8YlMUPJ3dr");
  609. NSLog(@"nKzvASJLedUylNmkfP1aBpE0oXcOIuT4");
  610. NSLog(@"dihOGqyJ1rgF5");
  611. NSLog(@"JX6wAaqPfHEvjV");
  612. NSLog(@"03KmA9P8C1oypQObUxHg7rZfXLBSVc6");
  613. NSLog(@"r2uIFLkipOJ8DCGVRqjn7afTmvX63hc9YPBsH");
  614. }
  615. -(void)ay19j5mv:(UIControl*) ay19j5mv akY49:(UIImageView*) akY49 aVMk1:(UIMenuItem*) aVMk1 aIU1rp5Xe:(UIRegion*) aIU1rp5Xe a4KF3:(UIAlertView*) a4KF3 azCvET:(UIImage*) azCvET aBnt7Qewf:(UIControlEvents*) aBnt7Qewf aOCVxfdH:(UIImageView*) aOCVxfdH a0m8ZwaqEMz:(UIBarButtonItem*) a0m8ZwaqEMz aQTDaP:(UIFont*) aQTDaP aFDXMZlq:(UIControlEvents*) aFDXMZlq aEJ6PDxXVB:(UIDevice*) aEJ6PDxXVB atBEMrQ:(UIVisualEffectView*) atBEMrQ akPVd:(UIImageView*) akPVd aOe2o:(UISearchBar*) aOe2o aQkfam:(UIView*) aQkfam aoNQZwSxHM:(UIDevice*) aoNQZwSxHM aOImRvt2FT:(UILabel*) aOImRvt2FT {
  616. NSLog(@"FrcWeZDmaNG8MRxKH9BLl6q4");
  617. NSLog(@"QTA2tWYKH5j");
  618. NSLog(@"UjAsILv7bhQ5x12lGOq68BawyHEofVMDJKS");
  619. NSLog(@"tdwF6ivbBqXE4szof7HeQV");
  620. NSLog(@"tu8PSaJD5iy4qBZkcvhYomsInlxK2gVwe16");
  621. NSLog(@"S9AOcLkT3601gswFhopIn");
  622. NSLog(@"3xhDqkPESpLQzVHOt2jbo7na4KvlGwNM8");
  623. NSLog(@"wG8XH6b0sRta");
  624. NSLog(@"NhWscLzXJqy6AmYHtZ");
  625. NSLog(@"2QDmpLnK108V5kqSf");
  626. NSLog(@"MzeUp80EOhJXn1ygjPFTiB");
  627. NSLog(@"rm5ohjASsX40ITaLVZyDNiJv");
  628. NSLog(@"QinaO8HDT1Zy7A0kqUcr4JRsoMwhjx3F");
  629. NSLog(@"wkD3eLVhKOCoHpmYQzcs");
  630. NSLog(@"uhrivdLHbKzj");
  631. NSLog(@"ybz5c4wNdosp2PlFvreO");
  632. }
  633. @end