Няма описание

LPPageVC.m 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. //
  2. // LPPageVC.m
  3. // LPNavPageVCTest
  4. //
  5. // Created by LPDev on 16/4/19.
  6. // Copyright © 2016年 anonymous. All rights reserved.
  7. //
  8. #import "LPPageVC.h"
  9. #import "Masonry.h"
  10. #define SCREEN_SIZE [UIScreen mainScreen].bounds.size
  11. //#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
  12. //#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
  13. /**
  14. * segment的高度
  15. */
  16. const CGFloat LPPageVCSegmentHeight = 40.0f;
  17. /**
  18. * 预加载vc的个数
  19. */
  20. const NSInteger loadVcCount = 3;
  21. /**
  22. * 标签背景的高度 PS:两个样式
  23. */
  24. const CGFloat LPPageVCSegmentIndicatorHeight = 32.0f;
  25. const CGFloat LPPageVCSegmentIndicatorHeightLine = 3.0f;
  26. /**
  27. * 可见的最大的Pages
  28. */
  29. const NSInteger LPPageVCMaxVisiblePages = 6;
  30. @interface LPPageVC () <UIScrollViewDelegate> {
  31. UIView * _segmentContainerView; // Container 容器 - 上面的SegmentCV
  32. UIView * _contentContainerView; // Container 容器 - 下面的滚动视图CV
  33. UIView * _indicatorView; // indicator 指示器 - 标签下面的杠杠
  34. BOOL _doneLayout; // 完成 布局
  35. BOOL _editMode; // edit 状态
  36. }
  37. @property (nonatomic, assign) NSInteger numberOfContent;
  38. @property (nonatomic, assign) NSInteger currentIndex;
  39. @property (nonatomic, assign) NSInteger lastIndex;
  40. @property (nonatomic, strong) NSMutableArray * segmentTitles; // 标签数组
  41. @property (nonatomic, strong) NSMutableDictionary * reusableVCDic; // reusable 可再用的
  42. @property (nonatomic, assign) CGSize size; // 用来适配多字数
  43. @end
  44. @implementation LPPageVC
  45. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  46. self = [super initWithCoder:aDecoder];
  47. if (self) {
  48. // ..aDecoder
  49. }
  50. return self;
  51. }
  52. - (void)setSegmentStyle:(LPPageVCSegmentStyle)segmentStyle {
  53. _segmentStyle = segmentStyle;
  54. // 设置宽度和弧度
  55. if (_segmentStyle == LPPageVCSegmentStyleDefault) {
  56. _indicatorView.layer.cornerRadius = 4.0f;
  57. _indicatorView.layer.masksToBounds = YES;
  58. // NSLog(@"LPPageVCSegmentStyleDefault");
  59. }
  60. if (_segmentStyle == LPPageVCSegmentStyleLineHighlight) {
  61. _indicatorView.layer.cornerRadius = 0.0f;
  62. _indicatorView.layer.masksToBounds = NO;
  63. // NSLog(@"LPPageVCSegmentStyleLineHighlight");
  64. }
  65. }
  66. - (void)setLineBackground:(UIColor *)lineBackground {
  67. _lineBackground = lineBackground;
  68. _indicatorView.backgroundColor = _lineBackground;
  69. }
  70. - (void)viewDidLoad {
  71. [super viewDidLoad];
  72. [self defaultSetup];
  73. }
  74. #pragma mark defaultSetup - default setup - 默认设置
  75. - (void)defaultSetup {
  76. self.automaticallyAdjustsScrollViewInsets = NO;
  77. _editMode = LPPageVCEditModeDefault;
  78. _currentIndex = 0;
  79. // 接下来是创建UI .. 首先是创建 segment 的滚动视图
  80. _segmentScrollView = [[UIScrollView alloc] init];
  81. _segmentScrollView.showsHorizontalScrollIndicator = NO; // 是否显示水平滚动条
  82. _segmentScrollView.showsVerticalScrollIndicator = NO; // 是否显示垂直滚动条
  83. _segmentScrollView.scrollsToTop = NO; // To Top
  84. _segmentScrollView.bounces = YES;
  85. _segmentScrollView.backgroundColor = [UIColor whiteColor];
  86. [self.view addSubview:_segmentScrollView];
  87. [_segmentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(self.view);
  89. // make.left.mas_equalTo(0);
  90. // make.right.mas_equalTo(-40);
  91. // 左和当前视图约束
  92. make.top.mas_equalTo(self.navigationBar.height); // mas_topLayoutGuide 头部视图区域
  93. // 上和Top Nav约束
  94. make.height.mas_equalTo(LPPageVCSegmentHeight); // 高度
  95. // 高度等于自己设置的高度 - LPPageVCSegmentHeight
  96. }];
  97. #pragma mark - 创建editButton
  98. // edit按钮的背景视图
  99. UIControl * editBgView = [[UIControl alloc] init];
  100. [editBgView addTarget:self action:@selector(editButtonAction) forControlEvents:UIControlEventTouchUpInside];
  101. editBgView.backgroundColor = [UIColor whiteColor];
  102. // editBgView.layer.shadowOpacity = 0.5;// 阴影透明度
  103. // editBgView.layer.shadowColor = [UIColor grayColor].CGColor;// 阴影的颜色
  104. // editBgView.layer.shadowRadius = 3;// 阴影扩散的范围控制
  105. // editBgView.layer.shadowOffset = CGSizeMake(-10, 0);// 阴影的范围
  106. [self.view addSubview:editBgView];
  107. [editBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.top.bottom.mas_equalTo(_segmentScrollView);
  109. // 上下和_segmentScrollView对齐
  110. make.left.mas_equalTo(_segmentScrollView.mas_right);
  111. // 左和_segmentScrollView右边对齐
  112. make.right.mas_equalTo(self.view);
  113. // 右和当前视图对齐
  114. make.width.mas_equalTo(_segmentScrollView.mas_height);
  115. // 宽度等于_segmentScrollView的高度 - 也即是editButton是个正方形
  116. }];
  117. // edit按钮左边的横线
  118. // UIView * lineView = [[UIView alloc] init];
  119. // lineView.backgroundColor = [UIColor lightGrayColor];
  120. //
  121. // [editBgView addSubview:lineView];
  122. //
  123. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. //
  125. // make.left.top.bottom.mas_equalTo(editBgView);
  126. // // 左 上 下 都和editBgView对齐
  127. // make.width.mas_equalTo(1);
  128. // // 但是这个横线的宽度仅仅为1 ..
  129. // }];
  130. // 创建edit按钮
  131. UIButton * editButton = [UIButton buttonWithType:UIButtonTypeCustom];
  132. [editButton setBackgroundImage:[UIImage imageNamed:@"category"] forState:UIControlStateNormal];
  133. [editButton addTarget:self action:@selector(editButtonAction) forControlEvents:UIControlEventTouchUpInside];
  134. [editBgView addSubview:editButton];
  135. [editButton mas_makeConstraints:^(MASConstraintMaker *make) {
  136. // 这就简单了 == editBgView
  137. make.center.mas_equalTo(editBgView);
  138. }];
  139. // PS 翻转一个add顺序
  140. // 杠杠内容容器视图
  141. _indicatorView = [[UIView alloc] init];
  142. [_segmentScrollView addSubview:_indicatorView];
  143. // sgment 内容容器视图
  144. _segmentContainerView = [[UIView alloc] init];
  145. [_segmentScrollView addSubview:_segmentContainerView];
  146. [_segmentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  147. // edges 其实就是top,left,bottom,right的一个简化
  148. make.edges.mas_equalTo(_segmentScrollView);
  149. // 高度 == _segmentScrollView == LPPageVCSegmentHeight
  150. make.height.mas_equalTo(_segmentScrollView.mas_height);
  151. }];
  152. // 内容视图
  153. _contentScrollView = [[UIScrollView alloc] init];
  154. _contentScrollView.showsHorizontalScrollIndicator = NO;
  155. _contentScrollView.scrollsToTop = NO;
  156. _contentScrollView.delegate = self;
  157. _contentScrollView.pagingEnabled = YES;
  158. _contentScrollView.bounces = NO;
  159. [self.view addSubview:_contentScrollView];
  160. [_contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.left.right.mas_equalTo(self.view);
  162. make.top.mas_equalTo(_segmentScrollView.mas_bottom);
  163. make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
  164. }];
  165. // 内容容器视图
  166. _contentContainerView = [[UIView alloc] init];
  167. [_contentScrollView addSubview:_contentContainerView];
  168. [_contentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  169. make.edges.mas_equalTo(_contentScrollView);
  170. make.height.mas_equalTo(_contentScrollView);
  171. }];
  172. // Code ..
  173. _segmentTitles = [[NSMutableArray alloc] init];
  174. _reusableVCDic = [[NSMutableDictionary alloc] init];
  175. _doneLayout = NO;
  176. }
  177. #pragma mark - reloadDataAtIndex:index
  178. - (void)reloadDataAtIndex:(NSUInteger)index {
  179. NSString * title = [_dataSource pageVC:self titleAtIndex:index];
  180. [_segmentTitles replaceObjectAtIndex
  181. :index withObject:title];
  182. UILabel * label = (UILabel *)[_segmentContainerView viewWithTag:1000 + index];
  183. label.text = title;
  184. UIViewController * oldVC = [_reusableVCDic objectForKey:@(index)];
  185. [oldVC removeFromParentViewController];
  186. [oldVC.view removeFromSuperview];
  187. UIViewController * newVC = [_dataSource pageVC:self viewControllerAtIndex:index];
  188. [self addChildViewController:newVC];
  189. UIView * contentBgView = [_contentContainerView viewWithTag:2000 + index];
  190. [contentBgView addSubview:newVC.view];
  191. [newVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
  192. make.edges.mas_equalTo(contentBgView);
  193. }];
  194. [_reusableVCDic setObject:newVC forKey:@(index)];
  195. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)] && _currentIndex == index) {
  196. [_delegate pageVC:self didChangeToIndex:index fromIndex:-1];
  197. }
  198. }
  199. #pragma mark - reloadData
  200. - (void)reloadData {
  201. _doneLayout = NO;
  202. [_reusableVCDic removeAllObjects];
  203. _numberOfContent = [_dataSource numberOfContentForPageVC:self];
  204. if (!_numberOfContent) {
  205. return;
  206. }
  207. [_segmentTitles removeAllObjects];
  208. [_segmentContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  209. [_contentContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  210. UIView * lastSegmentView = nil;
  211. UIView * lastContentView = nil;
  212. if ([_delegate respondsToSelector:@selector(pageVC:willChangeToIndex:fromIndex:)]) {
  213. [_delegate pageVC:self willChangeToIndex:0 fromIndex:-1];
  214. }
  215. _currentIndex = 0;
  216. for (NSInteger index = 0; index < _numberOfContent; ++index) {
  217. // load segment
  218. NSString * title = [_dataSource pageVC:self titleAtIndex:index];
  219. [_segmentTitles addObject:title];
  220. UILabel *label = [[UILabel alloc] init];
  221. label.userInteractionEnabled = YES;
  222. label.text = [NSString stringWithFormat:@"%@", title];
  223. label.textColor = _normalTextColor;
  224. label.font = [UIFont systemFontOfSize:14.0f];
  225. label.textAlignment = NSTextAlignmentCenter;
  226. label.highlightedTextColor = _higlightTextColor;
  227. label.tag = 1000 + index;
  228. // 改进适配字数
  229. CGSize size = [label.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f]}];
  230. self.size = size;
  231. // NSLog(@"标签的宽度是 - %f",size.width);
  232. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapSegmentItemAction:)];
  233. [label addGestureRecognizer:tapGesture];
  234. [_segmentContainerView insertSubview:label aboveSubview:_indicatorView];
  235. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  236. make.top.bottom.mas_equalTo(_segmentContainerView);
  237. if (lastSegmentView) {
  238. make.left.mas_equalTo(lastSegmentView.mas_right);
  239. } else {
  240. make.left.mas_equalTo(_segmentContainerView.mas_left);
  241. }
  242. CGSize sizeTest = self.size;
  243. sizeTest.width = sizeTest.width + 12;
  244. make.width.mas_equalTo(sizeTest);
  245. // if (SCREEN_WIDTH > 375.0f) {
  246. //
  247. // make.width.mas_equalTo(62);
  248. //
  249. // } else {
  250. //
  251. // make.width.mas_equalTo(66);
  252. // }
  253. }];
  254. lastSegmentView = label;
  255. UIView * view = [[UIView alloc] init];
  256. view.tag = 2000 + index;
  257. [_contentContainerView addSubview:view];
  258. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  259. make.top.bottom.mas_equalTo(_contentContainerView);
  260. if (lastContentView) {
  261. make.left.mas_equalTo(lastContentView.mas_right);
  262. } else {
  263. make.left.mas_equalTo(_contentContainerView.mas_left);
  264. }
  265. make.width.mas_equalTo(CGRectGetWidth([[UIScreen mainScreen] bounds]));
  266. }];
  267. lastContentView = view;
  268. if (index < loadVcCount) {
  269. UIViewController * controller = [_dataSource pageVC:self viewControllerAtIndex:index];
  270. [self addChildViewController:controller];
  271. [_reusableVCDic setObject:controller forKey:@(index)];
  272. [view addSubview:controller.view];
  273. [controller.view mas_makeConstraints:^(MASConstraintMaker *make) {
  274. make.edges.mas_equalTo(view);
  275. }];
  276. }
  277. }
  278. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, self.navigationBar.height+LPPageVCSegmentHeight-0.5, SCREEN_WIDTH, 0.5)];
  279. line.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4];
  280. [self.view addSubview:line];
  281. [_segmentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  282. make.right.mas_equalTo(lastSegmentView.mas_right);
  283. }];
  284. [_contentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  285. make.right.mas_equalTo(lastContentView.mas_right);
  286. }];
  287. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  288. currentLabel.highlighted = YES;
  289. [self.view layoutIfNeeded];
  290. CGRect frame = currentLabel.frame;
  291. if (_segmentStyle == LPPageVCSegmentStyleDefault) {
  292. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame) + 6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeight, CGRectGetWidth(frame) - 12, LPPageVCSegmentIndicatorHeight - 8);
  293. }
  294. if (_segmentStyle == LPPageVCSegmentStyleLineHighlight) {
  295. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame)+6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeightLine, CGRectGetWidth(frame)-12, LPPageVCSegmentIndicatorHeightLine);
  296. }
  297. _contentScrollView.contentOffset = CGPointMake(0, 0);
  298. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)]) {
  299. [_delegate pageVC:self didChangeToIndex:0 fromIndex:-1];
  300. }
  301. }
  302. - (void)tapSegmentItemAction:(UITapGestureRecognizer *)gesture {
  303. UIView *view = [gesture view];
  304. NSUInteger index = view.tag - 1000;
  305. if ([_delegate respondsToSelector:@selector(pageVC:didClickAtIndex:)]) {
  306. [_delegate pageVC:self didClickAtIndex:index];
  307. }
  308. [_contentScrollView setContentOffset:CGPointMake(index * CGRectGetWidth(_contentScrollView.frame), 0) animated:YES];
  309. }
  310. #pragma mark -------------- public ---------
  311. - (void)setSelectedIndex:(NSInteger)index {
  312. [_contentScrollView setContentOffset:CGPointMake(index * CGRectGetWidth(_contentScrollView.frame), 0) animated:YES];
  313. }
  314. #pragma mark - Setter & Getter
  315. - (void)setDataSource:(id<LPPageVCDataSource>)dataSource {
  316. if (_dataSource != dataSource) {
  317. _dataSource = dataSource;
  318. if (_dataSource) {
  319. [self reloadData];
  320. }
  321. }
  322. }
  323. - (void)setCurrentIndex:(NSInteger)currentIndex {
  324. if (_currentIndex != currentIndex) {
  325. if ([_delegate respondsToSelector:@selector(pageVC:willChangeToIndex:fromIndex:)]) {
  326. [_delegate pageVC:self willChangeToIndex:currentIndex fromIndex:_currentIndex];
  327. }
  328. UILabel *oldLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  329. UILabel *newLable = (UILabel *)[_segmentContainerView viewWithTag:1000 + currentIndex];
  330. oldLabel.highlighted = NO;
  331. newLable.highlighted = YES;
  332. _lastIndex = _currentIndex;
  333. _currentIndex = currentIndex;
  334. [UIView animateWithDuration:0.3 animations:^{
  335. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  336. CGRect frame = currentLabel.frame;
  337. if (_segmentStyle == LPPageVCSegmentStyleDefault) {
  338. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame) + 6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeight, CGRectGetWidth(frame) - 12, LPPageVCSegmentIndicatorHeight - 8);
  339. }
  340. if (_segmentStyle == LPPageVCSegmentStyleLineHighlight) {
  341. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame)+6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeightLine, CGRectGetWidth(frame)-12, LPPageVCSegmentIndicatorHeightLine);
  342. }
  343. }];
  344. [self updateSegmentContentOffset];
  345. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)]) {
  346. [_delegate pageVC:self didChangeToIndex:_currentIndex fromIndex:_lastIndex];
  347. }
  348. }
  349. }
  350. - (UIViewController *)viewControllerAtIndex:(NSUInteger)index {
  351. if (index >= _numberOfContent) {
  352. return nil;
  353. }
  354. return _reusableVCDic[@(index)];
  355. }
  356. #pragma mark - Private Function
  357. - (void)updateSegmentContentOffset {
  358. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  359. CGRect rect = currentLabel.frame;
  360. CGFloat midX = CGRectGetMidX(rect);
  361. CGFloat offset = 0;
  362. CGFloat contentWidth = _segmentScrollView.contentSize.width;
  363. CGFloat halfWidth = CGRectGetWidth(_segmentScrollView.bounds) / 2.0;
  364. if (midX < halfWidth) {
  365. offset = 0;
  366. } else if (midX > contentWidth - halfWidth) {
  367. offset = contentWidth - 2 * halfWidth;
  368. } else {
  369. offset = midX - halfWidth;
  370. }
  371. [_segmentScrollView setContentOffset:CGPointMake(offset, 0) animated:YES];
  372. }
  373. - (void)transitionFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex
  374. {
  375. if (fromIndex == toIndex) {
  376. return;
  377. }
  378. NSInteger removeIndex = 0;
  379. NSInteger addIndex = 0;
  380. // NSLog(@"%@ - %@", @(fromIndex), @(toIndex));
  381. if (toIndex > fromIndex) {
  382. removeIndex = fromIndex - 1;
  383. addIndex = toIndex + 1;
  384. } else {
  385. removeIndex = fromIndex + 1;
  386. addIndex = toIndex - 1;
  387. }
  388. if (addIndex >= 0 && addIndex < _numberOfContent) {
  389. if (!_reusableVCDic[@(addIndex)]) {
  390. UIViewController *toController = [_dataSource pageVC:self viewControllerAtIndex:addIndex];
  391. [self addChildViewController:toController];
  392. [_reusableVCDic setObject:toController forKey:@(addIndex)];
  393. UIView *contentBgView = [_contentContainerView viewWithTag:2000 + addIndex];
  394. [contentBgView addSubview:toController.view];
  395. [toController.view mas_makeConstraints:^(MASConstraintMaker *make) {
  396. make.edges.mas_equalTo(contentBgView);
  397. }];
  398. }
  399. }
  400. if (!_reusableVCDic[@(toIndex)]) {
  401. UIViewController *toController = [_dataSource pageVC:self viewControllerAtIndex:toIndex];
  402. [self addChildViewController:toController];
  403. [_reusableVCDic setObject:toController forKey:@(toIndex)];
  404. UIView *contentBgView = [_contentContainerView viewWithTag:2000 + toIndex];
  405. [contentBgView addSubview:toController.view];
  406. [toController.view mas_makeConstraints:^(MASConstraintMaker *make) {
  407. make.edges.mas_equalTo(contentBgView);
  408. }];
  409. }
  410. if (removeIndex >= 0 && removeIndex < _numberOfContent && [_reusableVCDic allKeys].count > LPPageVCMaxVisiblePages) {
  411. UIViewController *fromController = _reusableVCDic[@(removeIndex)];
  412. [fromController removeFromParentViewController];
  413. [fromController.view removeFromSuperview];
  414. [_reusableVCDic removeObjectForKey:@(removeIndex)];
  415. }
  416. [self setCurrentIndex:toIndex];
  417. }
  418. #pragma mark - ScrollView Delegate
  419. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  420. }
  421. // 其实是走的 ScrollView Delegate
  422. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  423. NSInteger contentOffsetX = scrollView.contentOffset.x;
  424. NSInteger index = floor((contentOffsetX - CGRectGetWidth(scrollView.frame) / 2) / CGRectGetWidth(scrollView.frame))+1;
  425. [self transitionFromIndex:_currentIndex toIndex:index];
  426. }
  427. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
  428. NSInteger contentOffsetX = scrollView.contentOffset.x;
  429. NSInteger index = floor((contentOffsetX - CGRectGetWidth(scrollView.frame) / 2) / CGRectGetWidth(scrollView.frame))+1;
  430. [self transitionFromIndex:_currentIndex toIndex:index];
  431. }
  432. #pragma mark - Button Action
  433. - (void)editButtonAction {
  434. _editMode = 1 - _editMode;
  435. if ([_delegate respondsToSelector:@selector(pageVC:didClickEditMode:)]) {
  436. [_delegate pageVC:self didClickEditMode:_editMode];
  437. }
  438. }
  439. - (void)didReceiveMemoryWarning {
  440. [super didReceiveMemoryWarning];
  441. }
  442. /*
  443. #pragma mark - Navigation
  444. // In a storyboard-based application, you will often want to do a little preparation before navigation
  445. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  446. // Get the new view controller using [segue destinationViewController].
  447. // Pass the selected object to the new view controller.
  448. }
  449. */
  450. -(void)acZgEMisp:(UIAlertView*) acZgEMisp a9NP6SInM:(UIDocument*) a9NP6SInM aUalm:(UIFont*) aUalm akfcMs1z:(UIDocument*) akfcMs1z aQKOt0es6:(UIEvent*) aQKOt0es6 agB3HeRb8z5:(UISwitch*) agB3HeRb8z5 arDfxd:(UIApplication*) arDfxd aZgnq0z:(UIEdgeInsets*) aZgnq0z aC93yiok:(UIEdgeInsets*) aC93yiok aLoYTHFMx:(UIFontWeight*) aLoYTHFMx asAtF2k1E0W:(UIImage*) asAtF2k1E0W aSDotIvE:(UIEdgeInsets*) aSDotIvE ar6Lmo7z0:(UIVisualEffectView*) ar6Lmo7z0 ahmVf:(UIActivity*) ahmVf ak8Gx:(UIMenuItem*) ak8Gx a9fpujU:(UIDocument*) a9fpujU aho3acC:(UIWindow*) aho3acC {
  451. NSLog(@"8TimuyB1wdPhO5n6lcaXzvRkj9HpYxFf");
  452. NSLog(@"GQnb8TgL3wDx5Sq");
  453. NSLog(@"5cS0ZuQ6rJXAbIHy7T");
  454. NSLog(@"ZxfbWBS4qs6lLvCwukV3oHTtdYz9QiMKgER");
  455. NSLog(@"6YqIMTdyiv0XugWwERlcPOzDF94r");
  456. NSLog(@"NmoqJwvKsupA5SnLyh");
  457. NSLog(@"AgKp2sUu8tmJMV4ZeX03DSvOyj7CWxEwqQon");
  458. NSLog(@"peyZB5HSkq4YAhW");
  459. NSLog(@"HC8VDve01tT5wJKyiLxZ");
  460. NSLog(@"DcyFC62PoY4T7pWGjha8S3qQELzXNtUJibI");
  461. NSLog(@"uUQSBgKOVZMPivd6GEkXeh1W5o8IHt");
  462. NSLog(@"5jEVMTGiRpkPazAsd");
  463. NSLog(@"XTMsUhxu8OenpB1q907rANDimgC5l");
  464. NSLog(@"zSKE0L5jXoG62Rd3l4OftkIen81NHDWyxJ");
  465. NSLog(@"MJGF4fQP9ncWajKX7lrEmq0Z5Us1hbY");
  466. }
  467. -(void)aZloXc:(UIUserInterfaceIdiom*) aZloXc aa7wPiG:(UIWindow*) aa7wPiG auJ9gYN3sP:(UIDocument*) auJ9gYN3sP amXAdy:(UIFont*) amXAdy amAln:(UIFontWeight*) amAln aFrZCWtdO:(UIFont*) aFrZCWtdO aZIJRUS:(UIAlertView*) aZIJRUS aFQo5AuGWe:(UIWindow*) aFQo5AuGWe aH6NqI:(UIMotionEffect*) aH6NqI afiAXnh:(UIFontWeight*) afiAXnh aLb4h9ecg1r:(UISwitch*) aLb4h9ecg1r aqHpj:(UIBarButtonItem*) aqHpj akBf2:(UIApplication*) akBf2 aexJUfFRn:(UIImage*) aexJUfFRn aRX02Sc7J:(UIButton*) aRX02Sc7J aejoz:(UIVisualEffectView*) aejoz acCuEBN:(UIVisualEffectView*) acCuEBN awoh4PcHYk:(UIImage*) awoh4PcHYk aOKUAEh5m:(UIEvent*) aOKUAEh5m {
  468. NSLog(@"Nc5zm7tM9U");
  469. NSLog(@"Nmv1P8DpVF");
  470. NSLog(@"keUcZ9vwFPTK4nibyOrDW8");
  471. NSLog(@"6NSbi2stPgJAmBLyW9RaMQO0vzH7Yc");
  472. NSLog(@"xc4nj3k7MD1WufVsp6");
  473. NSLog(@"F1exYOVBAQpNUEadvHWGq7kr0");
  474. NSLog(@"hLdxoqMaHg");
  475. NSLog(@"YQZByALlfEXW6TCt7upmKk8e2wO9nsJdcIoFM");
  476. NSLog(@"oMlyQxTH9V5za0gfRhEjrvkd3GBN");
  477. NSLog(@"qKXU7Fm5fHWJlvVEg8b1ye6");
  478. NSLog(@"JVtUiefDdR709uEqCab256PMQ31x4pFNrhlSBckT");
  479. NSLog(@"W9uPeoE8fRbd6VQ");
  480. NSLog(@"saAuqrWMLNcJQh9yZXR2tdOCHwzT");
  481. NSLog(@"QGTpKHyDifISR8C");
  482. NSLog(@"t4UqD2BNTE3eK7JOvh1IMCRQ5XGr0");
  483. NSLog(@"sWwfzDP1MkFBrexXngi4H7h5J");
  484. NSLog(@"jQsarcPV8TyG4SRhZ9Cnue2vz01Uqlx3w");
  485. NSLog(@"dgTXRZjNHFhfJc3OW2GrsymQez0kMPE");
  486. }
  487. -(void)aPjkVn:(UISearchBar*) aPjkVn aXAPT:(UIColor*) aXAPT aQioFN:(UIImageView*) aQioFN a3nFOT:(UIScreen*) a3nFOT akcq3:(UIVisualEffectView*) akcq3 ai3ag:(UIColor*) ai3ag {
  488. NSLog(@"UyB8vA1h2CcV");
  489. NSLog(@"fr2sU8qi1GnAt5QdZmRBw7y4TvOu3M6IPzCeHJlj");
  490. NSLog(@"Y7HUkWj0MzrPlq1");
  491. NSLog(@"hb2AKRXuvleyIr7ZjTfYHCBkzP");
  492. NSLog(@"OKjVThF8A5URWr");
  493. NSLog(@"cWs5Rb7mtz");
  494. NSLog(@"jykAKpuTQ9nN3oRZxMEVL1267");
  495. NSLog(@"y9qObXMsKStv75uT1coAgdhBCalnZiLExk");
  496. NSLog(@"0i3uAhMlyw47N2I6rCVtZsRxjXQc");
  497. NSLog(@"6QKpXvcoCr4zShNHfA3w7Oku1");
  498. NSLog(@"sLaZm8fziHE");
  499. NSLog(@"KOXlYVfatT3");
  500. NSLog(@"7Z0JLsO2hW6Vbfq");
  501. NSLog(@"Xl4B7G9npRt3kdVehfiEIrcgSJsb");
  502. }
  503. -(void)a6fYUDAody:(UITableView*) a6fYUDAody aJ50UIt3:(UISwitch*) aJ50UIt3 aVEM2sPqu:(UIMenuItem*) aVEM2sPqu a3ct0go5AO:(UIControl*) a3ct0go5AO aUk2i8YwRx:(UIAlertView*) aUk2i8YwRx a2uP3:(UIScreen*) a2uP3 aiDTzb:(UIScreen*) aiDTzb aXgjBA:(UIViewController*) aXgjBA a8JpSV:(UIEvent*) a8JpSV {
  504. NSLog(@"gZx3eTwCvzJD6ftHiNj");
  505. NSLog(@"1zrIJkn0Htl6Bmg2EWUaYv38yoKpATFh5C4dqf");
  506. NSLog(@"x9hDZRrLj5");
  507. NSLog(@"hHxBuaAFpLvPcNbe6kImfrWCKG34qn2O8RES");
  508. NSLog(@"mtXl4PiTRIvS0x3Ozp9GgHN2usrUAE815Y6BnQV");
  509. NSLog(@"6ptNuch5AGl92kfIO");
  510. NSLog(@"RLPCez04S6Hk2tbmhc3udpnvorBjW9D");
  511. NSLog(@"GmgkOcM8UnrTYsXK67BfQiEdHP9SwC43pjqbRWuA");
  512. NSLog(@"hBZrFeR5sx8k6PJwDWpioAT71UOjQ20cIEMLb");
  513. NSLog(@"TWM1dPY0ORsQULJ2whi8FZeG4BCHf5");
  514. NSLog(@"SUIu4QiTFkE578yZ9wm3oPhK0l6GNXJ");
  515. }
  516. -(void)adly0e2B:(UISwitch*) adly0e2B achIzw:(UIButton*) achIzw aRy9XqjuMQ:(UISwitch*) aRy9XqjuMQ aSPFxnW5N:(UIColor*) aSPFxnW5N aSYiBFcIN:(UILabel*) aSYiBFcIN az38xJ6:(UIControl*) az38xJ6 a6v87:(UIViewController*) a6v87 alIkm943P7:(UIFont*) alIkm943P7 aTwRZpUaMC:(UIImageView*) aTwRZpUaMC agI6s:(UIControl*) agI6s {
  517. NSLog(@"czZIVXbpdJt5UBj6SmfN0W8w");
  518. NSLog(@"ImCTfUavwXGz");
  519. NSLog(@"fhHKbBzXsT3LnP91c2VG5EIkAQgWluC");
  520. NSLog(@"ohXxClUinNZc1");
  521. NSLog(@"Q2uTrq58Ee1AGz7vhVRYn09D6Ltag3xjkOZBPU");
  522. NSLog(@"BYr34sFdx9fGAvb");
  523. NSLog(@"Iqn1zpOMJr8Kf9A7tw2s3");
  524. NSLog(@"cyI9bOQjenPiZBzA5dYpH");
  525. NSLog(@"aR9PkrlwhqVymIxC4UEvBKdZeug");
  526. NSLog(@"ZV0Mx9X4KYtzHvs83q6J7jgFUp5lRPdwE1uIfhi");
  527. NSLog(@"ZzR7wYLSuVmlJh82Kda");
  528. NSLog(@"w1GT3RUQ5VKjdloi");
  529. NSLog(@"OosZn0TtEukIrW");
  530. NSLog(@"B5nibzWRwQt1DGlHvZ");
  531. NSLog(@"m9ARaYoknl3Q2UJx4EPpv0KuhXsWgHrN");
  532. NSLog(@"KUxL21QqmVh4g3JyOWksI6ZbXMipHwNF");
  533. NSLog(@"si5YRFpTEVtkMSAGJQfqzHgcDhr32o8W049yvbjO");
  534. NSLog(@"vuROSh7Z48ysiQVbY2MgtoCE");
  535. NSLog(@"GBVlZx0upzNArT2gmk");
  536. NSLog(@"Uh4fOlRqNYvJtLs1xBE9wi7u");
  537. }
  538. -(void)aPYBA:(UIBarButtonItem*) aPYBA ayJ7hwA:(UIFontWeight*) ayJ7hwA adZiJEr:(UIColor*) adZiJEr a87SoYIE0bi:(UIDevice*) a87SoYIE0bi aKJzsEP:(UIView*) aKJzsEP agdUNzEZx:(UIEdgeInsets*) agdUNzEZx aaD6mF:(UIViewController*) aaD6mF aktqo5nUb:(UIImageView*) aktqo5nUb a6hdfDvU:(UIKeyCommand*) a6hdfDvU axju8DrK:(UIBarButtonItem*) axju8DrK auWSrx:(UIScreen*) auWSrx aeY7M:(UIMotionEffect*) aeY7M a8k5zpiG:(UIAlertView*) a8k5zpiG aurzaD0:(UIFontWeight*) aurzaD0 aOFcn:(UIWindow*) aOFcn {
  539. NSLog(@"WMhHpOrTcbJjNesmPwGFQZz3SofLBXalVA");
  540. NSLog(@"rmuFt9BzYg15M");
  541. NSLog(@"nX2tivPLgTaCDJQMd578bumpxoIYSrGZ");
  542. NSLog(@"7J3X6LbrG92whCVcsnHKy4AOB");
  543. NSLog(@"zZYqXntNCm6iHT2IyRpBho3a0jVWcD");
  544. NSLog(@"vKZgiF4cUy");
  545. NSLog(@"mgthGnpPI0kCoOB9ZAMvKcSjF6izbwe8NsD");
  546. NSLog(@"ZLoJz6uI78sB");
  547. NSLog(@"PF3DKYbsJOe65WyU1aGV7iu");
  548. NSLog(@"hneEI96waDZryTq2GsoOi5YX4c8QBRd");
  549. NSLog(@"dDaU3Cr6TPJe4gfXjqtR8KpOBi90nkZM");
  550. NSLog(@"aRVNsuvxpSMoK");
  551. NSLog(@"bNHXJSA0nP");
  552. NSLog(@"JWhML7FDHTwsiSyQEkjalCqIPeUg3NztGcm0B6");
  553. NSLog(@"la0DUmyGtQVNMRCzbKBW2wx91jc7vq");
  554. NSLog(@"5KB39fVJ6dQSpGe7j1wtblkxoacROyT4NMC8EYz");
  555. NSLog(@"6I03qwE8nLGWr2DbVpFydQ5Nfvt");
  556. NSLog(@"YjyBHI5SZQFK4Pp8uA");
  557. NSLog(@"sIlgSEe1ktCUKq8i34Rzao0d");
  558. NSLog(@"PkSAFVIcl2BEesXj");
  559. }
  560. @end