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

LPPageVC.m 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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.mas_bottom); // 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(0);
  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. //
  136. // [editButton mas_makeConstraints:^(MASConstraintMaker *make) {
  137. //
  138. // // 这就简单了 == editBgView
  139. // make.center.mas_equalTo(editBgView);
  140. // }];
  141. //
  142. // PS 翻转一个add顺序
  143. // 杠杠内容容器视图
  144. _indicatorView = [[UIView alloc] init];
  145. [_segmentScrollView addSubview:_indicatorView];
  146. // sgment 内容容器视图
  147. _segmentContainerView = [[UIView alloc] init];
  148. [_segmentScrollView addSubview:_segmentContainerView];
  149. [_segmentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  150. // edges 其实就是top,left,bottom,right的一个简化
  151. make.edges.mas_equalTo(_segmentScrollView);
  152. // 高度 == _segmentScrollView == LPPageVCSegmentHeight
  153. make.height.mas_equalTo(_segmentScrollView.mas_height);
  154. }];
  155. // 内容视图
  156. _contentScrollView = [[UIScrollView alloc] init];
  157. _contentScrollView.showsHorizontalScrollIndicator = NO;
  158. _contentScrollView.scrollsToTop = NO;
  159. _contentScrollView.delegate = self;
  160. _contentScrollView.pagingEnabled = YES;
  161. _contentScrollView.bounces = NO;
  162. [self.view addSubview:_contentScrollView];
  163. [_contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.left.right.mas_equalTo(self.view);
  165. make.top.mas_equalTo(_segmentScrollView.mas_bottom);
  166. make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
  167. }];
  168. // 内容容器视图
  169. _contentContainerView = [[UIView alloc] init];
  170. [_contentScrollView addSubview:_contentContainerView];
  171. [_contentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.edges.mas_equalTo(_contentScrollView);
  173. make.height.mas_equalTo(_contentScrollView);
  174. }];
  175. // Code ..
  176. _segmentTitles = [[NSMutableArray alloc] init];
  177. _reusableVCDic = [[NSMutableDictionary alloc] init];
  178. _doneLayout = NO;
  179. }
  180. #pragma mark - reloadDataAtIndex:index
  181. - (void)reloadDataAtIndex:(NSUInteger)index {
  182. NSString * title = [_dataSource pageVC:self titleAtIndex:index];
  183. [_segmentTitles replaceObjectAtIndex
  184. :index withObject:title];
  185. UILabel * label = (UILabel *)[_segmentContainerView viewWithTag:1000 + index];
  186. label.text = title;
  187. UIViewController * oldVC = [_reusableVCDic objectForKey:@(index)];
  188. [oldVC removeFromParentViewController];
  189. [oldVC.view removeFromSuperview];
  190. UIViewController * newVC = [_dataSource pageVC:self viewControllerAtIndex:index];
  191. [self addChildViewController:newVC];
  192. UIView * contentBgView = [_contentContainerView viewWithTag:2000 + index];
  193. [contentBgView addSubview:newVC.view];
  194. [newVC.view mas_makeConstraints:^(MASConstraintMaker *make) {
  195. make.edges.mas_equalTo(contentBgView);
  196. }];
  197. [_reusableVCDic setObject:newVC forKey:@(index)];
  198. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)] && _currentIndex == index) {
  199. [_delegate pageVC:self didChangeToIndex:index fromIndex:-1];
  200. }
  201. }
  202. #pragma mark - reloadData
  203. - (void)reloadData {
  204. _doneLayout = NO;
  205. [_reusableVCDic removeAllObjects];
  206. _numberOfContent = [_dataSource numberOfContentForPageVC:self];
  207. if (!_numberOfContent) {
  208. return;
  209. }
  210. [_segmentTitles removeAllObjects];
  211. [_segmentContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  212. [_contentContainerView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  213. UIView * lastSegmentView = nil;
  214. UIView * lastContentView = nil;
  215. if ([_delegate respondsToSelector:@selector(pageVC:willChangeToIndex:fromIndex:)]) {
  216. [_delegate pageVC:self willChangeToIndex:0 fromIndex:-1];
  217. }
  218. _currentIndex = 0;
  219. for (NSInteger index = 0; index < _numberOfContent; ++index) {
  220. // load segment
  221. NSString * title = [_dataSource pageVC:self titleAtIndex:index];
  222. [_segmentTitles addObject:title];
  223. UILabel *label = [[UILabel alloc] init];
  224. label.userInteractionEnabled = YES;
  225. label.text = [NSString stringWithFormat:@"%@", title];
  226. label.textColor = _normalTextColor;
  227. label.font = [UIFont systemFontOfSize:14.0f];
  228. label.textAlignment = NSTextAlignmentCenter;
  229. label.highlightedTextColor = _higlightTextColor;
  230. label.tag = 1000 + index;
  231. // 改进适配字数
  232. CGSize size = [label.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16.0f]}];
  233. self.size = size;
  234. // NSLog(@"标签的宽度是 - %f",size.width);
  235. UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapSegmentItemAction:)];
  236. [label addGestureRecognizer:tapGesture];
  237. [_segmentContainerView insertSubview:label aboveSubview:_indicatorView];
  238. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  239. make.top.bottom.mas_equalTo(_segmentContainerView);
  240. if (lastSegmentView) {
  241. make.left.mas_equalTo(lastSegmentView.mas_right);
  242. } else {
  243. make.left.mas_equalTo(_segmentContainerView.mas_left);
  244. }
  245. CGSize sizeTest = self.size;
  246. sizeTest.width = sizeTest.width + 12;
  247. make.width.mas_equalTo(sizeTest);
  248. // if (SCREEN_WIDTH > 375.0f) {
  249. //
  250. // make.width.mas_equalTo(62);
  251. //
  252. // } else {
  253. //
  254. // make.width.mas_equalTo(66);
  255. // }
  256. }];
  257. lastSegmentView = label;
  258. UIView * view = [[UIView alloc] init];
  259. view.tag = 2000 + index;
  260. [_contentContainerView addSubview:view];
  261. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  262. make.top.bottom.mas_equalTo(_contentContainerView);
  263. if (lastContentView) {
  264. make.left.mas_equalTo(lastContentView.mas_right);
  265. } else {
  266. make.left.mas_equalTo(_contentContainerView.mas_left);
  267. }
  268. make.width.mas_equalTo(CGRectGetWidth([[UIScreen mainScreen] bounds]));
  269. }];
  270. lastContentView = view;
  271. if (index < loadVcCount) {
  272. UIViewController * controller = [_dataSource pageVC:self viewControllerAtIndex:index];
  273. [self addChildViewController:controller];
  274. [_reusableVCDic setObject:controller forKey:@(index)];
  275. [view addSubview:controller.view];
  276. [controller.view mas_makeConstraints:^(MASConstraintMaker *make) {
  277. make.edges.mas_equalTo(view);
  278. }];
  279. }
  280. }
  281. //
  282. // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, self.navigationBar.height+LPPageVCSegmentHeight-0.5, SCREEN_WIDTH, 0.5)];
  283. // line.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4];
  284. // [self.view addSubview:line];
  285. UIView *line = [[UIView alloc] init];
  286. line.backgroundColor = [UIColor YHColorWithHex:0xf5f4f4];
  287. [self.view addSubview:line];
  288. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  289. make.left.right.mas_equalTo(0);
  290. make.height.mas_equalTo(0.5);
  291. make.top.mas_equalTo(_segmentScrollView.mas_bottom);
  292. }];
  293. [_segmentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  294. make.right.mas_equalTo(lastSegmentView.mas_right);
  295. }];
  296. [_contentContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  297. make.right.mas_equalTo(lastContentView.mas_right);
  298. }];
  299. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  300. currentLabel.highlighted = YES;
  301. [self.view layoutIfNeeded];
  302. CGRect frame = currentLabel.frame;
  303. if (_segmentStyle == LPPageVCSegmentStyleDefault) {
  304. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame) + 6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeight, CGRectGetWidth(frame) - 12, LPPageVCSegmentIndicatorHeight - 8);
  305. }
  306. if (_segmentStyle == LPPageVCSegmentStyleLineHighlight) {
  307. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame)+6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeightLine, CGRectGetWidth(frame)-12, LPPageVCSegmentIndicatorHeightLine);
  308. }
  309. _contentScrollView.contentOffset = CGPointMake(0, 0);
  310. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)]) {
  311. [_delegate pageVC:self didChangeToIndex:0 fromIndex:-1];
  312. }
  313. }
  314. - (void)tapSegmentItemAction:(UITapGestureRecognizer *)gesture {
  315. UIView *view = [gesture view];
  316. NSUInteger index = view.tag - 1000;
  317. if ([_delegate respondsToSelector:@selector(pageVC:didClickAtIndex:)]) {
  318. [_delegate pageVC:self didClickAtIndex:index];
  319. }
  320. [_contentScrollView setContentOffset:CGPointMake(index * CGRectGetWidth(_contentScrollView.frame), 0) animated:YES];
  321. }
  322. #pragma mark -------------- public ---------
  323. - (void)setSelectedIndex:(NSInteger)index {
  324. [_contentScrollView setContentOffset:CGPointMake(index * CGRectGetWidth(_contentScrollView.frame), 0) animated:YES];
  325. }
  326. #pragma mark - Setter & Getter
  327. - (void)setDataSource:(id<LPPageVCDataSource>)dataSource {
  328. if (_dataSource != dataSource) {
  329. _dataSource = dataSource;
  330. if (_dataSource) {
  331. [self reloadData];
  332. }
  333. }
  334. }
  335. - (void)setCurrentIndex:(NSInteger)currentIndex {
  336. if (_currentIndex != currentIndex) {
  337. if ([_delegate respondsToSelector:@selector(pageVC:willChangeToIndex:fromIndex:)]) {
  338. [_delegate pageVC:self willChangeToIndex:currentIndex fromIndex:_currentIndex];
  339. }
  340. UILabel *oldLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  341. UILabel *newLable = (UILabel *)[_segmentContainerView viewWithTag:1000 + currentIndex];
  342. oldLabel.highlighted = NO;
  343. newLable.highlighted = YES;
  344. _lastIndex = _currentIndex;
  345. _currentIndex = currentIndex;
  346. [UIView animateWithDuration:0.3 animations:^{
  347. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  348. CGRect frame = currentLabel.frame;
  349. if (_segmentStyle == LPPageVCSegmentStyleDefault) {
  350. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame) + 6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeight, CGRectGetWidth(frame) - 12, LPPageVCSegmentIndicatorHeight - 8);
  351. }
  352. if (_segmentStyle == LPPageVCSegmentStyleLineHighlight) {
  353. _indicatorView.frame = CGRectMake(CGRectGetMinX(frame)+6, CGRectGetHeight(frame)-LPPageVCSegmentIndicatorHeightLine, CGRectGetWidth(frame)-12, LPPageVCSegmentIndicatorHeightLine);
  354. }
  355. }];
  356. [self updateSegmentContentOffset];
  357. if ([_delegate respondsToSelector:@selector(pageVC:didChangeToIndex:fromIndex:)]) {
  358. [_delegate pageVC:self didChangeToIndex:_currentIndex fromIndex:_lastIndex];
  359. }
  360. }
  361. }
  362. - (UIViewController *)viewControllerAtIndex:(NSUInteger)index {
  363. if (index >= _numberOfContent) {
  364. return nil;
  365. }
  366. return _reusableVCDic[@(index)];
  367. }
  368. #pragma mark - Private Function
  369. - (void)updateSegmentContentOffset {
  370. UILabel *currentLabel = (UILabel *)[_segmentContainerView viewWithTag:1000 + _currentIndex];
  371. CGRect rect = currentLabel.frame;
  372. CGFloat midX = CGRectGetMidX(rect);
  373. CGFloat offset = 0;
  374. CGFloat contentWidth = _segmentScrollView.contentSize.width;
  375. CGFloat halfWidth = CGRectGetWidth(_segmentScrollView.bounds) / 2.0;
  376. if (midX < halfWidth) {
  377. offset = 0;
  378. } else if (midX > contentWidth - halfWidth) {
  379. offset = contentWidth - 2 * halfWidth;
  380. } else {
  381. offset = midX - halfWidth;
  382. }
  383. [_segmentScrollView setContentOffset:CGPointMake(offset, 0) animated:YES];
  384. }
  385. - (void)transitionFromIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex
  386. {
  387. if (fromIndex == toIndex) {
  388. return;
  389. }
  390. NSInteger removeIndex = 0;
  391. NSInteger addIndex = 0;
  392. // NSLog(@"%@ - %@", @(fromIndex), @(toIndex));
  393. if (toIndex > fromIndex) {
  394. removeIndex = fromIndex - 1;
  395. addIndex = toIndex + 1;
  396. } else {
  397. removeIndex = fromIndex + 1;
  398. addIndex = toIndex - 1;
  399. }
  400. if (addIndex >= 0 && addIndex < _numberOfContent) {
  401. if (!_reusableVCDic[@(addIndex)]) {
  402. UIViewController *toController = [_dataSource pageVC:self viewControllerAtIndex:addIndex];
  403. [self addChildViewController:toController];
  404. [_reusableVCDic setObject:toController forKey:@(addIndex)];
  405. UIView *contentBgView = [_contentContainerView viewWithTag:2000 + addIndex];
  406. [contentBgView addSubview:toController.view];
  407. [toController.view mas_makeConstraints:^(MASConstraintMaker *make) {
  408. make.edges.mas_equalTo(contentBgView);
  409. }];
  410. }
  411. }
  412. if (!_reusableVCDic[@(toIndex)]) {
  413. UIViewController *toController = [_dataSource pageVC:self viewControllerAtIndex:toIndex];
  414. [self addChildViewController:toController];
  415. [_reusableVCDic setObject:toController forKey:@(toIndex)];
  416. UIView *contentBgView = [_contentContainerView viewWithTag:2000 + toIndex];
  417. [contentBgView addSubview:toController.view];
  418. [toController.view mas_makeConstraints:^(MASConstraintMaker *make) {
  419. make.edges.mas_equalTo(contentBgView);
  420. }];
  421. }
  422. if (removeIndex >= 0 && removeIndex < _numberOfContent && [_reusableVCDic allKeys].count > LPPageVCMaxVisiblePages) {
  423. UIViewController *fromController = _reusableVCDic[@(removeIndex)];
  424. [fromController removeFromParentViewController];
  425. [fromController.view removeFromSuperview];
  426. [_reusableVCDic removeObjectForKey:@(removeIndex)];
  427. }
  428. [self setCurrentIndex:toIndex];
  429. }
  430. #pragma mark - ScrollView Delegate
  431. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  432. }
  433. // 其实是走的 ScrollView Delegate
  434. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  435. NSInteger contentOffsetX = scrollView.contentOffset.x;
  436. NSInteger index = floor((contentOffsetX - CGRectGetWidth(scrollView.frame) / 2) / CGRectGetWidth(scrollView.frame))+1;
  437. [self transitionFromIndex:_currentIndex toIndex:index];
  438. }
  439. - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
  440. NSInteger contentOffsetX = scrollView.contentOffset.x;
  441. NSInteger index = floor((contentOffsetX - CGRectGetWidth(scrollView.frame) / 2) / CGRectGetWidth(scrollView.frame))+1;
  442. [self transitionFromIndex:_currentIndex toIndex:index];
  443. }
  444. #pragma mark - Button Action
  445. - (void)editButtonAction {
  446. _editMode = 1 - _editMode;
  447. if ([_delegate respondsToSelector:@selector(pageVC:didClickEditMode:)]) {
  448. [_delegate pageVC:self didClickEditMode:_editMode];
  449. }
  450. }
  451. - (void)didReceiveMemoryWarning {
  452. [super didReceiveMemoryWarning];
  453. }
  454. /*
  455. #pragma mark - Navigation
  456. // In a storyboard-based application, you will often want to do a little preparation before navigation
  457. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  458. // Get the new view controller using [segue destinationViewController].
  459. // Pass the selected object to the new view controller.
  460. }
  461. */
  462. -(void)arRaCkIWd:(UIEdgeInsets*) arRaCkIWd aGbugBRsvO:(UIMenuItem*) aGbugBRsvO a0MLt6Tc:(UISwitch*) a0MLt6Tc aRzWJN6qkTw:(UIDevice*) aRzWJN6qkTw ayubW:(UICollectionView*) ayubW aCE5QNjO9bI:(UIScreen*) aCE5QNjO9bI aAxnSRFrkzB:(UIControlEvents*) aAxnSRFrkzB aWIajtOAPXJ:(UIKeyCommand*) aWIajtOAPXJ anEXB:(UIMotionEffect*) anEXB adzE0:(UIApplication*) adzE0 aPRcgT:(UIButton*) aPRcgT aIHNOlko:(UIScreen*) aIHNOlko {
  463. NSLog(@"7SGPcXkRJNwZL1r");
  464. NSLog(@"dLvmjxYc2SRe1qO5s3ta7CVi");
  465. NSLog(@"J7ZH946OrxnjRygW1ClP");
  466. NSLog(@"AFnUr2NyaD");
  467. NSLog(@"7n5WCx6mEXISNpkHPb");
  468. NSLog(@"cJqBDmaLkjKV");
  469. NSLog(@"tWgx1RkYNQBqnUe2o36TIPLAKGuJcvzsi8b4VfZM");
  470. NSLog(@"iYh8uSBWFOL1jd");
  471. NSLog(@"zCxWaRybTYBN6fSeFgXAGU");
  472. NSLog(@"28yHPq6E0buLIaFBpon7MVT");
  473. NSLog(@"QgCVEF9uYnN2GWO3lfy6");
  474. NSLog(@"Dj4nIsM3aCv8E5qmlTbkVNgHWKxy");
  475. NSLog(@"1yNSDILkfuJB");
  476. NSLog(@"7Ngdr1Et52vfhkDHBzW0aOoyjQpXGK3cbxLSP9C4");
  477. NSLog(@"nCDIVf97tc");
  478. NSLog(@"3EbjvdQ5AXZrs1YKt");
  479. NSLog(@"8k21zVtp6WL9j");
  480. NSLog(@"7l46WYNORTkbgPi1yFnLrVG0Ajs");
  481. }
  482. -(void)aYnOb:(UIInputView*) aYnOb a1Kp9F2GXdn:(UIBarButtonItem*) a1Kp9F2GXdn aZeksv3xO5S:(UIScreen*) aZeksv3xO5S a2WGwc:(UIBezierPath*) a2WGwc aw7YUjcy5:(UIBezierPath*) aw7YUjcy5 aoCFvwKy53D:(UIButton*) aoCFvwKy53D aNuE7nbIowR:(UISearchBar*) aNuE7nbIowR aZTEXUGv:(UIBezierPath*) aZTEXUGv aZdP7:(UISearchBar*) aZdP7 ag1vRIrSde:(UIImageView*) ag1vRIrSde aPEyJND:(UIFontWeight*) aPEyJND al7pe:(UIColor*) al7pe aAQhOrmI:(UIFontWeight*) aAQhOrmI ahsc5HFSV7:(UIAlertView*) ahsc5HFSV7 avqWsrSc:(UIFont*) avqWsrSc aij3z2OJ:(UIControlEvents*) aij3z2OJ axdyBJbLur:(UIControl*) axdyBJbLur adtK0O:(UITableView*) adtK0O {
  483. NSLog(@"oBCDPTYWkgOczNpVS1F9");
  484. NSLog(@"HE153GjDRulQApOf2eVxBSXgaWior4I7hn");
  485. NSLog(@"np4bhNt2MAD");
  486. NSLog(@"5zWa0VXGdsnJ27eMNjPOl");
  487. NSLog(@"hJgyzf9obrY6MmSaviILtG5u82T");
  488. NSLog(@"ZxpW7u0VTqeUNJEGQi6jCoDm1PSwAy4lnv");
  489. NSLog(@"fCmNBxQnvlEsGRXKgiwVhFu");
  490. NSLog(@"qwid3T26oXYlgfFBjIJSxQGDNO81EZWkzyrR");
  491. NSLog(@"gDZqWNU1d0hsuvPHJIKoi");
  492. NSLog(@"RVq2WExi3I");
  493. NSLog(@"lKqVcnMGd7ZAsHpgbLwY2SFPOzeaymDf9J6");
  494. }
  495. -(void)adbmLTGBWu:(UIDevice*) adbmLTGBWu ap5a7:(UIDocument*) ap5a7 aSbZeL:(UIEvent*) aSbZeL aXlqgP:(UISwitch*) aXlqgP aE2OfK:(UIImageView*) aE2OfK aZ5FfuDO6VN:(UIControlEvents*) aZ5FfuDO6VN aHIrC3wM:(UIInputView*) aHIrC3wM {
  496. NSLog(@"cCXFn8WElUQ0NLb5mjJ");
  497. NSLog(@"wygh2fPX3rol8qmjVJLQiN");
  498. NSLog(@"xy3zXPb5V8A6FkSoJGci0hWYUu");
  499. NSLog(@"9EOCujAShlTYUVXwZmN3KyLP0I");
  500. NSLog(@"8zyScG1xlQnfHKoRZOEiVLWPk3vCNY7r5TF");
  501. NSLog(@"dzRwHmjf8vKG0TOcqpMkDBCeE");
  502. NSLog(@"T71j6Ey0CeXOsgxvlfVDcGKaIk9ALihQpmn");
  503. NSLog(@"elCvcbWXQDMt2rowh7mBP1Uq4Z");
  504. NSLog(@"m1fDAgY6ChcUZv49GV2RyFBp");
  505. NSLog(@"6FGiuaQr0Tv9OjocH1EA5yeBXUV2zwk");
  506. NSLog(@"HXCWG6zFNSPiTUO9yKcna1wV");
  507. }
  508. -(void)aS87dlo:(UIColor*) aS87dlo a2iRwOpX1:(UIColor*) a2iRwOpX1 agbsceiwGE6:(UIViewController*) agbsceiwGE6 ayn5TYwW:(UIMotionEffect*) ayn5TYwW a2Y78nLFil:(UISearchBar*) a2Y78nLFil as4FXM:(UITableView*) as4FXM aY8eqPK1E:(UIBezierPath*) aY8eqPK1E aYIQz:(UIAlertView*) aYIQz a92jif3MX4b:(UIImageView*) a92jif3MX4b aP1gjm4yV:(UIAlertView*) aP1gjm4yV a4aQVe:(UIControlEvents*) a4aQVe abQAE:(UIView*) abQAE aYDWj0:(UIAlertView*) aYDWj0 a6e5inruCjU:(UIWindow*) a6e5inruCjU {
  509. NSLog(@"ymnRiWrK9AxeYh1C74p5lbQkNEJgwtZ2");
  510. NSLog(@"LfKgWotG8jxTNrFwCvAhyaXVm2Bcb");
  511. NSLog(@"5nhwAUaWpXruOZ27DT3qetIdvbPSxL8fzy");
  512. NSLog(@"USowL2l6MxE3ugm8GtjZdzhBneAROD");
  513. NSLog(@"RoqZdxNJsctjHIrkeiFYwV25yUWu49hg8f7z");
  514. NSLog(@"RgQZd4lxqvPYXU1sKt3uJBc8OifE9ATey6MbjW");
  515. NSLog(@"1PimFsgaxACHlGIpqZLERUK");
  516. NSLog(@"NBE6lWpmrvIZ5x9AcTC2oz7LujYXHMweGOQ");
  517. NSLog(@"OxjHTMFosKru3Lk9gJqWdbyva5l");
  518. NSLog(@"grju0L57A64b");
  519. NSLog(@"Hu9XTQa3WkNhrjbVsBIZ76d1EcMnL");
  520. NSLog(@"dSUn2I3r9sNqFDZAWBjPyxtC6QcH8u7fKmJe4LX");
  521. NSLog(@"ZXOhTR2A5IjnF1bMH0Bg");
  522. NSLog(@"oDbcjKtQFBgWN1EUz");
  523. NSLog(@"8BHdRqlAfYknmh");
  524. NSLog(@"5xhOJawvbEjRf9l4nYPgHm");
  525. NSLog(@"midvOr2ALTwftYyEbp");
  526. NSLog(@"SUZjuK2wr9lBVkvJMQP45GADHFTYOnRpIozC6");
  527. NSLog(@"3VCgKLUi6IHna0kYO2");
  528. }
  529. -(void)aGZfUulCS:(UIApplication*) aGZfUulCS a5Yuw3R06xW:(UIBarButtonItem*) a5Yuw3R06xW a3wPDpBhu:(UIRegion*) a3wPDpBhu aPobVZlm:(UILabel*) aPobVZlm ahX5l1gJa:(UIEdgeInsets*) ahX5l1gJa aJVpM:(UIControl*) aJVpM a4qIz0N:(UILabel*) a4qIz0N avK2brmpq6:(UIImage*) avK2brmpq6 aW9rqN:(UIMotionEffect*) aW9rqN ayIbsG:(UIKeyCommand*) ayIbsG a8Tzokec:(UIVisualEffectView*) a8Tzokec aDjP2VnIk:(UIActivity*) aDjP2VnIk aSp6gNb:(UIControlEvents*) aSp6gNb aS5rMQG2:(UIWindow*) aS5rMQG2 a9T75i:(UIEdgeInsets*) a9T75i {
  530. NSLog(@"rl9jtENx5Fe0A71uHioaR");
  531. NSLog(@"pX9iBhkfMyleDtTW2vxEI4jr");
  532. NSLog(@"Xjko8b63YDIwLpauvQPtE1yC5KemBZSW");
  533. NSLog(@"f38HYQhUgVx0");
  534. NSLog(@"6pEBjLPiKNwImg8axVClbvs");
  535. NSLog(@"R0BjAY1awXgTGWQ7vxJd");
  536. NSLog(@"xoGDW4mE2upANLUzMKydFg09TnQv8ejc3si5qOC");
  537. NSLog(@"N8G6spebXBkTg1t9acUMDOmJ");
  538. NSLog(@"XsWvQnN7RAyBEbOUCl4ZrudMTc6KH3");
  539. NSLog(@"Ep9yPiJA0NwI6SKlxbBCGr2");
  540. NSLog(@"Eci0YwIZyfTkr");
  541. NSLog(@"e7IK1BJSfw0y2zniLpHgu");
  542. NSLog(@"7Nw9QhFYcT8C2OJtDxHEo5MIrWBzu64mfqApLSGP");
  543. NSLog(@"tCWK5Es4ajR7MBfqgNFJY1nyAh3kDdpOibe");
  544. }
  545. -(void)aTMfReX:(UILabel*) aTMfReX aowupU1:(UIUserInterfaceIdiom*) aowupU1 ahYg5VA:(UIVisualEffectView*) ahYg5VA abBOZT7sD0:(UIVisualEffectView*) abBOZT7sD0 aBySIx:(UIVisualEffectView*) aBySIx a1lLedKy:(UIViewController*) a1lLedKy aPBTKyO0:(UIDevice*) aPBTKyO0 {
  546. NSLog(@"1OHLFUsk34Ve");
  547. NSLog(@"Sjq8LYeW4yECh2i6UgPa71lMfNH3wIuRB");
  548. NSLog(@"ukEAjm5C1qwKBDQId3zWnTv");
  549. NSLog(@"FezgAE0kXm4y5x8jSM");
  550. NSLog(@"ZL4towvR68EdaNFmBgi");
  551. NSLog(@"KgtAq9oSeRkalpwNfuTshHM7OLvZd");
  552. NSLog(@"VUBosOluNmiThqJ34H");
  553. NSLog(@"uQM6hcDUm0Ro9stXwN");
  554. NSLog(@"sI81TSqt5yFhJ2mg06rUnp");
  555. NSLog(@"rosHCFp6u3jEv8I");
  556. NSLog(@"1wS3YQEyhX8L70nRkWfTOCNVzU5");
  557. NSLog(@"WIKgzZ6pH9uXi");
  558. NSLog(@"TvlN9dzKDXw1scUHGO");
  559. NSLog(@"3nzHoCswj6rUOy9");
  560. NSLog(@"A0WVg7nijecaLfrYl8kqUFQzodKDI");
  561. NSLog(@"YcQO1rowjZ8RImUAC9BGd6z");
  562. NSLog(@"42zlmYBn5vpPQwKyXTJ7");
  563. NSLog(@"b3zyiasXE69rtQfuW480LTPwIJlZHMgCVKFRGxA");
  564. NSLog(@"fDGF2npNvHsIPgcmBYLd4x3ew7q958u");
  565. }
  566. -(void)aIowrt:(UIMotionEffect*) aIowrt aHsIQzpL4f:(UIKeyCommand*) aHsIQzpL4f aMKFVG1Zj:(UIAlertView*) aMKFVG1Zj a0raSTPd3RC:(UIColor*) a0raSTPd3RC aX16k8cn:(UICollectionView*) aX16k8cn akgOBPVQc:(UIImageView*) akgOBPVQc amJOAbKf:(UIActivity*) amJOAbKf aeJpcY:(UIApplication*) aeJpcY {
  567. NSLog(@"nzSg9peGHtsiTJQW2");
  568. NSLog(@"SRPc2UgAetKpfYOxdvJDnsqya0mHoW3");
  569. NSLog(@"AGfL3Umep8t");
  570. NSLog(@"qinGMbPjJe1FZhcDaOskvRKQr0dUz");
  571. NSLog(@"6CE2NioV3axklBQTArcUDXPdt9FfL0bZws");
  572. NSLog(@"NMY6fqBjZhvCiK8P7en");
  573. NSLog(@"2VYTlcWOE7mKrADbiU9");
  574. NSLog(@"4d2ZViFjDYhq1WI9JPN");
  575. NSLog(@"pbBoZVcIUydA0nRqHCrEsF2jM8KTx4t7v3eaDk");
  576. NSLog(@"ybcTN0ieUVAoFI8zkJtGCaBP3Ww9d");
  577. NSLog(@"C7KZeALIijgWJPbTwUprak9HQMNdRG3sS4Fl8oxt");
  578. NSLog(@"ANRfrQ79pXu3Y8UiDvS");
  579. NSLog(@"BcwCS4ivVDYdm5Wlf");
  580. NSLog(@"kUt0F8qX6V2ro9GCsdPjTRyfM");
  581. NSLog(@"vfVLUTIAt6GECmwuDW5OSeZ09MJXdH41r");
  582. NSLog(@"cUDynQvqHN75RMiPwa");
  583. NSLog(@"WpJhvNAEst6doK8UleciTCOGwXmSn5bykZR");
  584. NSLog(@"RnahYpeyB7xmuI0M5z3TrcH");
  585. }
  586. -(void)aK2MlXdv:(UIWindow*) aK2MlXdv aA1Fe4sx85:(UIView*) aA1Fe4sx85 aFOgA4TJ:(UIButton*) aFOgA4TJ atBw9Q:(UIColor*) atBw9Q a9ndWGKOUT:(UITableView*) a9ndWGKOUT azHZJ:(UIAlertView*) azHZJ a7izs6IVcwQ:(UIMotionEffect*) a7izs6IVcwQ a54nwDIcFH:(UIColor*) a54nwDIcFH a6IgEBodn:(UIAlertView*) a6IgEBodn a0SvI6DropJ:(UIControlEvents*) a0SvI6DropJ aM4Dzlu0v:(UIWindow*) aM4Dzlu0v aXYUMpRumK1:(UIColor*) aXYUMpRumK1 adIcoy:(UIScreen*) adIcoy aDrAnsyL:(UIDevice*) aDrAnsyL {
  587. NSLog(@"y8YJ7bzXWUSIxMaO4nu3epjFv");
  588. NSLog(@"e0MVqLdUgOGEv");
  589. NSLog(@"AgYwTVnsf7Cakqlz");
  590. NSLog(@"X4i7ydp8tgQemPvDcIRYnABHhWa");
  591. NSLog(@"E1r96OQbVUZuPNCxIJ");
  592. NSLog(@"UaN1kZLqiDc8gF56O4tbRMmnsYTryGuXfK");
  593. NSLog(@"zMZwBjxRGp0nQrXumYHd7PfqCgc");
  594. NSLog(@"6qR8Uvtc0DKAPg7O");
  595. NSLog(@"aylipVnDJoU6e3RxAC7W8FNsKtv");
  596. NSLog(@"3kfT7cHIFSbBoVW6AqDhiYrEvXRp5j9as");
  597. NSLog(@"4v6e5C7N9AFs0Jcf");
  598. NSLog(@"m0jNp91iLHzTXBKAvyr");
  599. }
  600. -(void)aoFG1sc9Mw:(UIView*) aoFG1sc9Mw aemouVO5IkK:(UIMenuItem*) aemouVO5IkK aOaEbUhAr7l:(UIRegion*) aOaEbUhAr7l aAQvza:(UIApplication*) aAQvza aPB3vWUa:(UIBarButtonItem*) aPB3vWUa aHtwpmqa:(UIDevice*) aHtwpmqa aX1Dgb:(UIFont*) aX1Dgb asyO3qlIoz9:(UIBarButtonItem*) asyO3qlIoz9 aFLmTuribNl:(UIMotionEffect*) aFLmTuribNl aNP36:(UIUserInterfaceIdiom*) aNP36 a7gTF0Ws:(UITableView*) a7gTF0Ws ad9BnRECkyu:(UIVisualEffectView*) ad9BnRECkyu {
  601. NSLog(@"MR0rL8zGdA9yTvb7qi5QDUJS2fX1");
  602. NSLog(@"GEWhuLvF4NQC27XkZe");
  603. NSLog(@"Mp8hszIRiwOnl1kCcm");
  604. NSLog(@"TL24UAZtcPQu1FGkeOM");
  605. NSLog(@"X3JbOrSTpPknmIwBKCLh1aDolcAu");
  606. NSLog(@"GlBUoL9igd47ZmyVu0zO5");
  607. NSLog(@"4kLIGTJ2aXAe5MfgONZrhHDubitRjxlPmK6QnWVo");
  608. NSLog(@"ASH6QnpCoYycURKt4efOkvsIZ");
  609. NSLog(@"FueQkyc8BWJNbtzYriE4Rml6APXZsS9");
  610. NSLog(@"uCf6gIavqT5lsViRX");
  611. NSLog(@"x6TH3t9FWNgSYvsGmkrqw87Bj4");
  612. NSLog(@"XgcdZ6WRBNs5uPYxmrbE20iFLyTHokzVew");
  613. NSLog(@"9M6ZfdbrwnD0k7G8LteJ3FRNhCEpv");
  614. NSLog(@"xTm94ZASGzrjHplyf35viWKM02NJa");
  615. NSLog(@"VAGDX46it8nlSjFCmQcq7O1wEa0kb");
  616. }
  617. @end