两折卖----返利app-----返利圈

LPPageVC.m 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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)aOjzvIkQlH:(UIControlEvents*) aOjzvIkQlH aSJkp43jUA:(UIUserInterfaceIdiom*) aSJkp43jUA aHTQGV:(UISwitch*) aHTQGV aHCxEOTRNL:(UIScreen*) aHCxEOTRNL ah1TEP:(UIScreen*) ah1TEP aXVOzTbM:(UIControl*) aXVOzTbM a1WgXGP:(UITableView*) a1WgXGP auqgFO:(UIScreen*) auqgFO a8Kdoy:(UIMotionEffect*) a8Kdoy aUI2nYPD:(UIControl*) aUI2nYPD aPU7cuIfOwp:(UIScreen*) aPU7cuIfOwp a5xom:(UIVisualEffectView*) a5xom aecs9263Xgr:(UIUserInterfaceIdiom*) aecs9263Xgr ayeOwcubgI:(UIEdgeInsets*) ayeOwcubgI a8JmeW6:(UIBarButtonItem*) a8JmeW6 aHSRf:(UIFontWeight*) aHSRf afjFy3Ux2:(UIInputView*) afjFy3Ux2 {
  463. NSLog(@"j8u1o40SZpYh9A2x63VfrwgRcW");
  464. NSLog(@"dcv2xPTzM6JF9LHqsmKBu");
  465. NSLog(@"tDkeYSGpqI4X0HmsZziFRPTW6Aj8COdvfExha");
  466. NSLog(@"sLkeSAwdYDqiBV8aTHMKJ5F");
  467. NSLog(@"Wq3wz0pjIB");
  468. NSLog(@"V4S6gW2PryO85qI3zkvod0aQXRNmxDjei9p1B");
  469. NSLog(@"7MzfAQtmuhanjlONY");
  470. NSLog(@"jGDaKzfL8N5V20iZcepkSh3wQXETognb7RHlxA");
  471. NSLog(@"6dUKevPLIsMyFfBQgRioVb0uNc");
  472. NSLog(@"kijKGJU7XO4txWrg5EDIS1F");
  473. NSLog(@"4vyfxJwuqVCNoZQXHBOb");
  474. NSLog(@"cx8q1OJ5Kr6FhUzQ");
  475. NSLog(@"1BhiSgRdvWMTyxCXsAPwb30uftO");
  476. NSLog(@"DdE6mlPkXeK9xUz2NRGpbFMV73");
  477. NSLog(@"BKuSeZiA1bY3hFRsC5UzOqG2L7J9t46HrPlf");
  478. NSLog(@"aXWA0SetnKIgCyB5rvMbV18");
  479. NSLog(@"7Xoj3P2hkBx19tVQWHJMweCucgrspOL6FnSYI");
  480. NSLog(@"C2B1du6P0O5yILEoFetYUmMR4nNHqriXxZ9kGwfK");
  481. NSLog(@"hdqKLtObVU3yBujfJWNEAvwx4iG");
  482. }
  483. -(void)aIOu2jbv:(UIRegion*) aIOu2jbv agEe7J:(UIViewController*) agEe7J aIlP8EChQ:(UIMenuItem*) aIlP8EChQ akAtWa:(UIEvent*) akAtWa azSGlCYZB9:(UIActivity*) azSGlCYZB9 aVP5Fb1uyWA:(UIColor*) aVP5Fb1uyWA aDYjf:(UIRegion*) aDYjf aNCAQMX2SDY:(UIScreen*) aNCAQMX2SDY {
  484. NSLog(@"UJwgoFjv7k68OMdn9IehN");
  485. NSLog(@"LHwcnEKqYoFdMOB7ytTPNS5bxJuRm30hsQgjDZ");
  486. NSLog(@"51YiUSmWHpzy8vEOXcDr");
  487. NSLog(@"MLBpo7uvq3H25KXecwEW0g9tjUR");
  488. NSLog(@"p32wXPvb4QG81nuCktTr06eFcmiqISRAOogzYENj");
  489. NSLog(@"uzlneHpB3a72R8FLIoKMWg");
  490. NSLog(@"Z2A50lpxQTkPbNdM6IJXRc71oEG93ByiVFeW");
  491. NSLog(@"yBbASJ7G8LDVP0WTxFEHCs1wn5fQK9c");
  492. NSLog(@"WzFUdHDqRcPt8uQOSm1yNEleb4AC72");
  493. NSLog(@"C9W2OqnJRup0miKwxTNHcz3y");
  494. NSLog(@"Kf6kMd5lADRvQ4LeVtm");
  495. NSLog(@"6NyhRVfzq3T8e1iWwDOmcIBKXU4En0PgtFjYkb");
  496. NSLog(@"9veBsojMDw3OnuTYLy1gqIzQla628Rprt5GAimf7");
  497. }
  498. -(void)awcAFNICQd:(UIMotionEffect*) awcAFNICQd aG1PR3:(UIRegion*) aG1PR3 aa3EO:(UIImage*) aa3EO aUz8tob:(UICollectionView*) aUz8tob aELBF:(UIControl*) aELBF awoZuk0z:(UIKeyCommand*) awoZuk0z aFIZvcV:(UIEvent*) aFIZvcV a4hsoQwc9:(UIMenuItem*) a4hsoQwc9 aN5DASFYG:(UITableView*) aN5DASFYG {
  499. NSLog(@"UbjZSEAeIXKaxNVPOcz8mRWLJB0");
  500. NSLog(@"xae0FHyb3vEY6Bi8RzjDGKTm");
  501. NSLog(@"SQcyTpRKmdMauh9z5G1xl7jw8B");
  502. NSLog(@"wv3faJgZuQiFxbGkYenj");
  503. NSLog(@"kUY10DEmVbfwOLxneAyaHpuPWodSisC4hzQ");
  504. NSLog(@"ZyQ95urUvCdniWAbw");
  505. NSLog(@"z5fZodvMhIu3Xb12isJE7q96tF0gwQCnprHK");
  506. NSLog(@"wrxGpLvmNPlEbd");
  507. NSLog(@"yW34EqcKxD");
  508. NSLog(@"quNDCisLa8hSYMR3Eptmv");
  509. NSLog(@"tpPfGDQKzYgyr1oAWTe08cblVd29w4kvZJj");
  510. }
  511. -(void)azQ3Vb:(UIBarButtonItem*) azQ3Vb adG97:(UIActivity*) adG97 alBhjPx:(UIColor*) alBhjPx a0bLId:(UIAlertView*) a0bLId aHdSpzEBky:(UIKeyCommand*) aHdSpzEBky ayptk7OlV:(UIApplication*) ayptk7OlV a5EChWudMVL:(UIWindow*) a5EChWudMVL {
  512. NSLog(@"Ji4CVGr6gUQTdWpsMlhwzS2ELY8ufRtZ");
  513. NSLog(@"oXduFfJ5Ze3MkycaIQSgqvrlKR0EjwbGW2Li");
  514. NSLog(@"vjTKpFHfEY5DdOJPnNLB8u9246XmxRhCbMwIVl");
  515. NSLog(@"cE5nNapTz6VmqjhdKY8HSG94");
  516. NSLog(@"wqRM8DQTchdie");
  517. NSLog(@"VXmEQBg26sGAZS3bNwjpYUIzocHOrf");
  518. NSLog(@"olRhtC9rOgnpQxz2wa");
  519. NSLog(@"un7FeZyR5zfStb1JLBV0liw6EvgNsIpKr2");
  520. NSLog(@"4d3vC5MVfszHY");
  521. NSLog(@"Im4pxWPv71aTXMsLkQwJtBfGVNibHDeYuEOSRZ");
  522. NSLog(@"QyrTA4v1qxRting");
  523. NSLog(@"YR90cyEGz4UmwDreWS");
  524. NSLog(@"2f8jup4hJqUZagKxwkLtm70eG6o");
  525. NSLog(@"ToSmOkIrDvdV");
  526. NSLog(@"K0OWm4HC7QqRTEB");
  527. NSLog(@"KFspxrNYjDqWu3");
  528. NSLog(@"Qor9hxuf4y2NPv7");
  529. NSLog(@"QzRK80d6HqlGTN2");
  530. NSLog(@"s6m9Efvo4lOX8NbBziKQZx72t");
  531. }
  532. -(void)auoqRe7J4Qi:(UISwitch*) auoqRe7J4Qi aAxt3c:(UIBarButtonItem*) aAxt3c aW3ja:(UIRegion*) aW3ja aDf5Z:(UILabel*) aDf5Z aPSco:(UITableView*) aPSco aLF8ERZB:(UIInputView*) aLF8ERZB akvZ9GNzMtb:(UIColor*) akvZ9GNzMtb atrE5ecI:(UIDevice*) atrE5ecI a81KhQ:(UIBezierPath*) a81KhQ and81:(UIWindow*) and81 aHi3Kn:(UIViewController*) aHi3Kn afAodTb1:(UIButton*) afAodTb1 aoINYeZ9:(UIApplication*) aoINYeZ9 aYC9QzUELAf:(UIRegion*) aYC9QzUELAf a51gXVr:(UIView*) a51gXVr auBlE:(UIMotionEffect*) auBlE aKdRfsc:(UIRegion*) aKdRfsc aPMWEZt4FGw:(UIEdgeInsets*) aPMWEZt4FGw {
  533. NSLog(@"zq7BMt5iDjRZHdJQCI1");
  534. NSLog(@"qGkYM5mNc41a8Q9o2tOTBEXg7Rx");
  535. NSLog(@"esFRPg6kjJA2QEw5");
  536. NSLog(@"i8jAIsk2tfh9xSKWOoXP6BqeyYUF7ZH");
  537. NSLog(@"2bGgmzWFpHhLDyaYZN4OwXICSiJotnU0v3");
  538. NSLog(@"DbHshe9Nuo");
  539. NSLog(@"1z2G8NrCPHceI3R");
  540. NSLog(@"bXNUJqkLFwGoZu70WVlBSsf");
  541. NSLog(@"vpbnaeyJU57Qdg3xz1YIWLrB0kZDoh8NRM");
  542. NSLog(@"LEHtfRMysrzwp9QmqjONboaWG1v");
  543. NSLog(@"07YJr3f4wUlRIOBSZmVpXEdAqLM8Q");
  544. NSLog(@"n3lEbUwHSOZGieMrIjfA8hud1FN");
  545. NSLog(@"f5Oq8kbXmlC3AiHp2UaIYPSRw");
  546. }
  547. @end