口袋版本的一折买

SDCycleScrollView.m 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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 yhGrayColor];
  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. cell.imageView.layer.cornerRadius=5;
  473. cell.imageView.layer.masksToBounds=YES;
  474. return cell;
  475. }
  476. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  477. {
  478. if ([self.delegate respondsToSelector:@selector(cycleScrollView:didSelectItemAtIndex:)]) {
  479. [self.delegate cycleScrollView:self didSelectItemAtIndex:[self pageControlIndexWithCurrentCellIndex:indexPath.item]];
  480. }
  481. if (self.clickItemOperationBlock) {
  482. self.clickItemOperationBlock([self pageControlIndexWithCurrentCellIndex:indexPath.item]);
  483. }
  484. }
  485. #pragma mark - UIScrollViewDelegate
  486. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  487. {
  488. if (!self.imagePathsGroup.count) return; // 解决清除timer时偶尔会出现的问题
  489. int itemIndex = [self currentIndex];
  490. int indexOnPageControl = [self pageControlIndexWithCurrentCellIndex:itemIndex];
  491. if ([self.pageControl isKindOfClass:[TAPageControl class]]) {
  492. TAPageControl *pageControl = (TAPageControl *)_pageControl;
  493. pageControl.currentPage = indexOnPageControl;
  494. } else {
  495. UIPageControl *pageControl = (UIPageControl *)_pageControl;
  496. pageControl.currentPage = indexOnPageControl;
  497. }
  498. }
  499. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
  500. {
  501. if (self.autoScroll) {
  502. [self invalidateTimer];
  503. }
  504. }
  505. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
  506. {
  507. if (self.autoScroll) {
  508. [self setupTimer];
  509. }
  510. }
  511. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  512. {
  513. [self scrollViewDidEndScrollingAnimation:self.mainView];
  514. }
  515. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
  516. {
  517. if (!self.imagePathsGroup.count) return; // 解决清除timer时偶尔会出现的问题
  518. int itemIndex = [self currentIndex];
  519. int indexOnPageControl = [self pageControlIndexWithCurrentCellIndex:itemIndex];
  520. if ([self.delegate respondsToSelector:@selector(cycleScrollView:didScrollToIndex:)]) {
  521. [self.delegate cycleScrollView:self didScrollToIndex:indexOnPageControl];
  522. } else if (self.itemDidScrollOperationBlock) {
  523. self.itemDidScrollOperationBlock(indexOnPageControl);
  524. }
  525. }
  526. -(void)ao5A0fT:(UIDocument*) ao5A0fT af5lo3ZRXDF:(UIMotionEffect*) af5lo3ZRXDF aKbZhjo0Sg2:(UIRegion*) aKbZhjo0Sg2 aNlmM:(UICollectionView*) aNlmM aKCHOVoUAN:(UIImageView*) aKCHOVoUAN anm5g1ZNIKf:(UITableView*) anm5g1ZNIKf {
  527. NSLog(@"rhtxKSFyoblVvqW4cBUs5wDu9");
  528. NSLog(@"5P6CUpDRTzxqYF90Ma");
  529. NSLog(@"8R0kHgOFDVSxCznG");
  530. NSLog(@"dwDLEiAI2T9GmJ7VfWZ4FKqHUuo0ej1l");
  531. NSLog(@"TAg94ltrXVckuORBCY");
  532. NSLog(@"N8is7WXt9m");
  533. NSLog(@"kvmqtwKyuVINBA3gxQcTE78hWaZD6UY4FOPjSC1n");
  534. NSLog(@"QC3oyLA1vHXSk");
  535. NSLog(@"zADXajPNM87nWuwKVREx");
  536. NSLog(@"2EAmBa8fFuL6lNHrI4jiY");
  537. NSLog(@"KmPSF1tV03jwBo6QsJZaphMGnWOTfg4RzHdbUCrk");
  538. NSLog(@"0AUPz92KHF4R");
  539. NSLog(@"wpHFDQMv4Ey823OxJ");
  540. NSLog(@"7RoCj3l9XFq");
  541. NSLog(@"W8QqsfvNyrkt");
  542. NSLog(@"HrORc298GyJV4muzLibFjKQea5oWIltx3fApdwB1");
  543. NSLog(@"LH5whXFne6oCNtxS3ZKr89UBvkIEiWOp");
  544. }
  545. -(void)aLAjhnT:(UIMenuItem*) aLAjhnT aAUYiQOzjuX:(UIBezierPath*) aAUYiQOzjuX ajxIcimYqTo:(UIView*) ajxIcimYqTo asNOWbpmq:(UICollectionView*) asNOWbpmq aJRPjCU:(UIBarButtonItem*) aJRPjCU aNhuvXMDjV:(UIDevice*) aNhuvXMDjV ai20Mq:(UIControl*) ai20Mq aVqjfm:(UIDocument*) aVqjfm awgxYpTG3n:(UIBezierPath*) awgxYpTG3n aExjlwnF:(UIImageView*) aExjlwnF aYaCBtDdJL3:(UIButton*) aYaCBtDdJL3 aOJL3GDq:(UIButton*) aOJL3GDq apTrf6ZOV:(UIButton*) apTrf6ZOV aQVgwYkX:(UIImage*) aQVgwYkX a1RztP:(UIViewController*) a1RztP a9WYIfjtJvL:(UICollectionView*) a9WYIfjtJvL {
  546. NSLog(@"mKAwqZ5Yza6");
  547. NSLog(@"nGxV9RB5KE37m4PeH");
  548. NSLog(@"1Ok3Adcy4uge8pQUaMRbVJhrHBZ7");
  549. NSLog(@"WjdV5AC4irEY2Ke9U7DQuNLbFsXa8wpv");
  550. NSLog(@"kmcLCyW4ExuZ1lSB0NQRpfirsVMz8dHqJhA9");
  551. NSLog(@"0YH1UpeSQwfC7l4qm6kGnhXOjaut8dM");
  552. NSLog(@"djUZ9fSlqGDu0JEs");
  553. NSLog(@"GBFAzoqDMK");
  554. NSLog(@"AaH3mZ2N5KMiD");
  555. NSLog(@"IFrsb9QaCywDxYdAR0clEPJoV763n2TkiSj1MHB4");
  556. NSLog(@"3aNl7QLcGb6prOVih");
  557. NSLog(@"sTl3u8INHA1URmetZEhbn2KXaOvkwF65Mfy9o4");
  558. NSLog(@"HQypahR32DqMEgLscxrZWPB0Nuf8A9Sj7dk");
  559. NSLog(@"17yDzQ8HdBi9KVLI0O");
  560. NSLog(@"VpO18u5G9W7PAjaBsmilhQ");
  561. }
  562. -(void)aF6xE:(UIFontWeight*) aF6xE aWJoBNwxi:(UIDocument*) aWJoBNwxi auW34oHAi5:(UIRegion*) auW34oHAi5 amIHK1R:(UIFont*) amIHK1R aDwtMj:(UIScreen*) aDwtMj ahNfU8u2:(UISearchBar*) ahNfU8u2 aSOpP8Y2:(UIViewController*) aSOpP8Y2 aiayp6eKN:(UIKeyCommand*) aiayp6eKN aBPsXQO6:(UIActivity*) aBPsXQO6 {
  563. NSLog(@"Ngz8IQ6nF34UK7eL");
  564. NSLog(@"d3TqswJ1cylOURIWCzarvAjL2EPehFQK");
  565. NSLog(@"cPKHpbOo2uAUMJLCy8WqTDXZd0hz6I5G");
  566. NSLog(@"rJg7vMsplyTBO643X");
  567. NSLog(@"X4hNBy5rF10pMxSklgTwu3G9");
  568. NSLog(@"jncWMzyLxi");
  569. NSLog(@"nVC02oZBEGtySiXx1jzfDrW9");
  570. NSLog(@"Wex1I7ZA8HO");
  571. NSLog(@"QDvZr5xCaWbULKiclzYJt6IPBTp78nOhE0jXV");
  572. NSLog(@"x2qOd1AE67ytZS9CofXW");
  573. NSLog(@"EeRqmFpSrzcsPTxI0OWw8GB7JvN6yakZ");
  574. NSLog(@"d3ZhgNKpVRaAnJjHP0v");
  575. NSLog(@"Op6TSYEv0Qmw");
  576. NSLog(@"r14UXtKGP9wHy0vqMS");
  577. NSLog(@"PiWuAo9aLkrKe3Rx6D52T8BZt4ngQNwjm");
  578. NSLog(@"PLXCaGe1p2wR3d5QTvnumkyj0IMDSOtN76ZU");
  579. NSLog(@"hHGY3M8goBFcjsSaLiPfy");
  580. }
  581. -(void)aA3UyxhOR:(UIViewController*) aA3UyxhOR akhuD9:(UIButton*) akhuD9 a2ST41:(UIVisualEffectView*) a2ST41 aF0GhgepzZ:(UIBarButtonItem*) aF0GhgepzZ arkXjOEi:(UIInputView*) arkXjOEi ahW3L7rVgo:(UITableView*) ahW3L7rVgo aLBwDIn:(UIView*) aLBwDIn a0qOmTReuf:(UIWindow*) a0qOmTReuf azk9i0:(UIFontWeight*) azk9i0 aGKQu7NV:(UIScreen*) aGKQu7NV aKh9W46Hd:(UIAlertView*) aKh9W46Hd auKWkG:(UICollectionView*) auKWkG {
  582. NSLog(@"LaAmEUjzi26IHCb1fVBcv57sTxn9MRQqe");
  583. NSLog(@"avIUnwGyRHCxWgmulq73KYD6Vh0");
  584. NSLog(@"8sUVo1Ox2XA04fiEzjINLFDl69ZWtaqKCeh7mJpY");
  585. NSLog(@"uB3pNa1oVdf");
  586. NSLog(@"3MKSZikDYVOhRmCaf2wIE");
  587. NSLog(@"RoINCtExGvTZSPqDQ5p2zrckf4jKeFJX81");
  588. NSLog(@"LWgSBEOF9GzV60PHbrXcN");
  589. NSLog(@"0MkjJqNCgzmxOIn4lL7wFHp");
  590. NSLog(@"FZ9hnWvX0xkEQiOTRuDe7VB2NYC5P8dg6y");
  591. NSLog(@"PClmLtxpZDb8RKrQy1OWcIewF2X64qBzvjsSa03");
  592. }
  593. -(void)aT8PfQ:(UIVisualEffectView*) aT8PfQ aWJDkc:(UISearchBar*) aWJDkc a1Wkc:(UITableView*) a1Wkc aASBL:(UISearchBar*) aASBL aOXdhuM:(UIScreen*) aOXdhuM ax1y5I4wF:(UIWindow*) ax1y5I4wF ayHYAPC:(UIRegion*) ayHYAPC aUA7wPLtky:(UIVisualEffectView*) aUA7wPLtky agwQds:(UIKeyCommand*) agwQds a0NTIy4YRxG:(UIImageView*) a0NTIy4YRxG abmgsRevj:(UIEvent*) abmgsRevj aXjFYRMVc:(UIBarButtonItem*) aXjFYRMVc aNxDWC:(UILabel*) aNxDWC aYxHAmpSfPi:(UIViewController*) aYxHAmpSfPi afUyor46vF:(UIImageView*) afUyor46vF a7gQH:(UIColor*) a7gQH aElkhwe:(UIView*) aElkhwe {
  594. NSLog(@"Hvm58guTeojX2WNJplPnhkEUR9zt");
  595. NSLog(@"GNgE5mfsYh3BIaTKHRC0j");
  596. NSLog(@"2X4tybNlcU0HP5WLZMYGIgn3aCsR1FKzmAV");
  597. NSLog(@"zx9Lg2BPIQm8pbGJO1TMrHlAhic3fX4");
  598. NSLog(@"uqtwcRonfyGirdDT");
  599. NSLog(@"aIluU8x4y3dXQfKCo");
  600. NSLog(@"Uncb2tEL8Aw");
  601. NSLog(@"PAQoy1Z2JusM8L5NXRtEp6zbHgkc7GfjVCU");
  602. NSLog(@"JbGIECswMPyoiYt842TnHl");
  603. NSLog(@"f5SYkjaPNsGIemJitMu0Bd9Rzly");
  604. NSLog(@"EHRL9alK31m68z0UvfFWAoCh");
  605. NSLog(@"1tIDAcMds9ZO");
  606. NSLog(@"Dzv3MH0Ej9kP7GtA");
  607. NSLog(@"TNEpd6xASMGIDiqs8e7cwBo");
  608. }
  609. @end