一折买app------返利---------返利宝

SDCycleScrollView.m 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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)alJ5CeaUR7c:(UIEvent*) alJ5CeaUR7c a01Hg:(UIViewController*) a01Hg aWyB6EGZQN:(UISearchBar*) aWyB6EGZQN anJTOsy:(UIScreen*) anJTOsy aKD4M:(UIActivity*) aKD4M aYgwCA:(UIKeyCommand*) aYgwCA aIHSATRgBVc:(UIFont*) aIHSATRgBVc auaYOp:(UIActivity*) auaYOp abvCUfEyP5:(UIControl*) abvCUfEyP5 awb4ahuBR7:(UIWindow*) awb4ahuBR7 aWmrKXA79:(UIDevice*) aWmrKXA79 aniHGpQKdo:(UILabel*) aniHGpQKdo a1z92M:(UISearchBar*) a1z92M aotqQDy:(UIRegion*) aotqQDy aulG51MxEK:(UITableView*) aulG51MxEK aSlfgkvIup:(UIScreen*) aSlfgkvIup {
  525. NSLog(@"PcsEJz8vyt3ge0Y1WOMrqTjxKDAVdQFNXaCZn");
  526. NSLog(@"2WkXKtYBrPvO");
  527. NSLog(@"w4vSjLFfzKEXPdog0NG2");
  528. NSLog(@"J7zcUTdRaKAe1IvGZxr");
  529. NSLog(@"joH6CRMUxhiJrd3pA9s");
  530. NSLog(@"NE9UpvMl4Vtn8J7jWL20CGoami6BkKq");
  531. NSLog(@"kIfxLSu2jclpmvD4ZnaqWdtUAKBg8Qw96rOTReCM");
  532. NSLog(@"w1K7BGXChNudnb2D6");
  533. NSLog(@"Pt9ouGLlYUpy");
  534. NSLog(@"zgbt2oXZ7q6pPjsK");
  535. NSLog(@"j51tY97RkJwAM0Gxvg4nyfoZBcW");
  536. NSLog(@"mbt485df6FLMNIOr");
  537. NSLog(@"gY5Prksao3HQ12xeui4RE9mIJc");
  538. NSLog(@"gE1W9YKulaq");
  539. NSLog(@"ktYblEKA7or3LHRczwaFSI0QgvVh8");
  540. NSLog(@"Y5izOclmrGNDgRHwkuB1ydV");
  541. NSLog(@"WzdxYFaNk6rotDeTQi4fbM");
  542. }
  543. -(void)aUsnSi9JAwY:(UIBarButtonItem*) aUsnSi9JAwY a4LlfEI:(UIEdgeInsets*) a4LlfEI aUktBd2jYng:(UIKeyCommand*) aUktBd2jYng aCDlqh:(UIBarButtonItem*) aCDlqh a5NsqXjPfb:(UIView*) a5NsqXjPfb akSOjG:(UIInputView*) akSOjG a4GJP50ch:(UIWindow*) a4GJP50ch aiXGwCl0:(UITableView*) aiXGwCl0 aGsgWE:(UIView*) aGsgWE aikfUO:(UIVisualEffectView*) aikfUO {
  544. NSLog(@"GTwpVgFJNER0jk2zIWm6q");
  545. NSLog(@"Fr0STNBvXM4ay8EQi3xZmYgftwubh6L1CeUKsDG");
  546. NSLog(@"W0UD92E1q3YBa");
  547. NSLog(@"b6sUwc1A5QDqEZxXVLmpIvClneOo2FRN");
  548. NSLog(@"HQRIierJuyKMPa");
  549. NSLog(@"ZuOEH7vlhS3wnmea0Q5UKD6x8");
  550. NSLog(@"UjCui6zoTeOvpMlKWS4mJGk0QsY");
  551. NSLog(@"9f4pVQ0IDJeAUgRx");
  552. NSLog(@"pchx2ikzbBJKsNwC9v6Eo0Q");
  553. NSLog(@"c23tTDiOAWjgkShBMXLJqwCUGlou");
  554. NSLog(@"h2YcjwtiUGNST1IQgvXRdLKHWA3mk78yu");
  555. NSLog(@"gYuSWm5QK3rEDaA0qGj7iVcTxzfJhlIUZnt");
  556. NSLog(@"Oo16vNbSJMi4xaC0q8s3wp7A5IXEk9lBVHeZumUW");
  557. NSLog(@"XOpWQz7Nh5t3eDjwPrcEq1m64uFYMJ");
  558. NSLog(@"uNH0h2kpVyvndqQf1GzZWtP85l9oacLTF");
  559. }
  560. -(void)aQseUa:(UIApplication*) aQseUa aBZU6:(UISwitch*) aBZU6 aC3XAft:(UICollectionView*) aC3XAft a5gIz1:(UILabel*) a5gIz1 ay0kSxu6b:(UIControlEvents*) ay0kSxu6b aS7TC:(UIEdgeInsets*) aS7TC aOXZhG:(UIMenuItem*) aOXZhG ajQZv:(UIVisualEffectView*) ajQZv a3BEWN10gad:(UIAlertView*) a3BEWN10gad az6JiU:(UIActivity*) az6JiU az34um:(UIBarButtonItem*) az34um aWlhjyH6mi:(UIRegion*) aWlhjyH6mi abEZfm2whL:(UIImageView*) abEZfm2whL aUGYsJc:(UIFont*) aUGYsJc aL0ne9Y:(UIImageView*) aL0ne9Y afZYIByw5:(UIDocument*) afZYIByw5 acElu:(UIAlertView*) acElu aCue4RM3wSn:(UIBarButtonItem*) aCue4RM3wSn aAmeWrMY:(UIBarButtonItem*) aAmeWrMY ayHcifZkp:(UIViewController*) ayHcifZkp {
  561. NSLog(@"MW8Z3w42TVrhflqb1xpocN5zudgRD7BJyGIQmPC");
  562. NSLog(@"9xomySdH1L6QAvMKTYVFq3wibpke");
  563. NSLog(@"r4uqS9DtbsRjkBYnvUmFTGdLgaI0Qfw3A28l6EJ");
  564. NSLog(@"y6F9NnGwp7");
  565. NSLog(@"LrHlPGUaAde6CuQk");
  566. NSLog(@"HezbicJga2pn41hRTU");
  567. NSLog(@"1PZhgB7UtXVu3bFd0Y5imS4ceCyEKzT");
  568. NSLog(@"Ptc2G4w1vx0zW");
  569. NSLog(@"sHKCXv89IfqJ2WOtVPrRBxLmcEj");
  570. NSLog(@"CJKXIOpZiM9j");
  571. NSLog(@"8dRl2Th3a6cyMYtALekG");
  572. NSLog(@"1CneIRG2KqoFYmxlDZ");
  573. NSLog(@"SJ7iTl4h6XL");
  574. NSLog(@"U7Nd5nTGLRAPcB");
  575. NSLog(@"hQX6SC94gWDPvoLiutYweBkTj780n1J");
  576. NSLog(@"DvLykxgXtEuT3zVbcwdA608CGneKS59fmo24IY");
  577. NSLog(@"07COEaJpZFfzh3kNlwGXHI9RKc5MUvd2sLbB6");
  578. }
  579. -(void)ao58NDc1I:(UILabel*) ao58NDc1I akV87nYG1hH:(UITableView*) akV87nYG1hH aBzq62ph:(UIButton*) aBzq62ph aOA6iT:(UIViewController*) aOA6iT aiSqH:(UIWindow*) aiSqH aQiNUyp:(UIFontWeight*) aQiNUyp a5eibI:(UIImage*) a5eibI a2kzhEu:(UISwitch*) a2kzhEu {
  580. NSLog(@"eiclGypbT3qVmB0ZNHtg4MrDK8");
  581. NSLog(@"eUudcA0yEwQvaLTMXH875iVhPkYo");
  582. NSLog(@"QCt0jnsr2cLOZNvK5ydJ8HkpSzVeB3hXDf");
  583. NSLog(@"T8YjxorfKHmPwcA3WXJDSdsqzubI6");
  584. NSLog(@"tvP2adJeXRCuxS4cWlk3");
  585. NSLog(@"f2Mv5e0DSJKYpzTHan");
  586. NSLog(@"78GZjYwSuvk0lzThUePm9cfX31LJ5gVOyQB");
  587. NSLog(@"3QvNEIsLRBtCZHKlf7Uc8GXoSk");
  588. NSLog(@"PAwcSqZCoOsGhKfWitM5YnXdbTD7N6xlmzrp38Jg");
  589. NSLog(@"4fZEHCRi80GogTNhwxMYmIaLSplbBtzqye5unrU9");
  590. NSLog(@"nJbANHTv5fFWegXy7s34ui");
  591. NSLog(@"62ROBnXbtCqpciy");
  592. NSLog(@"M9hPGp54uwDq0etJiIVSB3N2n");
  593. }
  594. -(void)aKs7CNr5Sp:(UIMenuItem*) aKs7CNr5Sp aW9iIYyb:(UISwitch*) aW9iIYyb aq4eiG:(UILabel*) aq4eiG adO0C1HyckD:(UIBarButtonItem*) adO0C1HyckD a8Mg1cp0Cun:(UIFontWeight*) a8Mg1cp0Cun azCEo:(UIScreen*) azCEo a79N31icTe:(UISwitch*) a79N31icTe a5R2tTVCgB:(UIControl*) a5R2tTVCgB aZ6ejc:(UIRegion*) aZ6ejc ajO3B:(UIApplication*) ajO3B a8tZyDe:(UISwitch*) a8tZyDe ajNKloa0:(UIViewController*) ajNKloa0 afIXQlY:(UIAlertView*) afIXQlY aY5jIkPUM:(UILabel*) aY5jIkPUM ax5ubs:(UIActivity*) ax5ubs {
  595. NSLog(@"0aLPWA6dblQJu2w7igFhKeTIkCVMtpO");
  596. NSLog(@"PzucLH60S4axe7qNGtfTnYJMjpDmEv");
  597. NSLog(@"RAPrjMQbqIv8pt6EV9xKNz43Xi");
  598. NSLog(@"h3pxuPJQyli2Uft");
  599. NSLog(@"obH5cRD8iEkzQYx6Os");
  600. NSLog(@"LwU54znjvsiPgERG");
  601. NSLog(@"5Axy3fXhqms7lCnbr0tKDN6");
  602. NSLog(@"94f1AKH0Wo2gR5u");
  603. NSLog(@"rkcutC1QslS3hNYL");
  604. NSLog(@"vukUygxfwnOhWlNe0HTYzVRd6rPZK5oJ");
  605. NSLog(@"nHMks2F9KWmJrpS5fw8hzQblGEie");
  606. }
  607. -(void)aXmeRpk:(UIBezierPath*) aXmeRpk aaJw3:(UIViewController*) aaJw3 aHeChM7z8I:(UIMotionEffect*) aHeChM7z8I ahSqE:(UIBezierPath*) ahSqE at9S7HZh3F:(UIInputView*) at9S7HZh3F aOF6pxdA:(UIButton*) aOF6pxdA aShpckO:(UILabel*) aShpckO avLNsAt8:(UIUserInterfaceIdiom*) avLNsAt8 aAmXVP:(UIBezierPath*) aAmXVP amD4WB2tVld:(UIColor*) amD4WB2tVld aOd3P:(UIVisualEffectView*) aOd3P a2QKWj:(UILabel*) a2QKWj aOZyXB2eEx:(UIEvent*) aOZyXB2eEx aq5BRMVAvI:(UIFontWeight*) aq5BRMVAvI a5FDM614Spd:(UIRegion*) a5FDM614Spd axvZPz:(UIScreen*) axvZPz aZcqnO:(UIApplication*) aZcqnO aPQXJxat4u:(UIWindow*) aPQXJxat4u {
  608. NSLog(@"dIEmzCLNRQeixJtDfpAv4XwFo");
  609. NSLog(@"3yKvJruOxFqDisXd72");
  610. NSLog(@"tRc93jbTwXuJW2");
  611. NSLog(@"XPmW3ObcfZ");
  612. NSLog(@"Boy87pJ1LsZGHi30KkSx4tQFjXc");
  613. NSLog(@"7xjmZOEnX1PStUKY3kApuz0HWgGwb5v8");
  614. NSLog(@"A48FbhgQGRTxz9Xn0");
  615. NSLog(@"GvFmtSQplMabc7");
  616. NSLog(@"e7pq5WEIgaY3K");
  617. NSLog(@"zwjfhTgLrly7A4SkOdQsW0IqaJ3HKZD26oepNu");
  618. NSLog(@"BoMt6hxFUTg41JDEsmOzG0XcaHqWSv3RCw8YI");
  619. NSLog(@"ghVm93fdyEiMqZRwkKsF7I6t4bDUJac15PN");
  620. }
  621. @end