酷店

KDPCollectHistoryPageVC.m 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // KDPCollectHistoryPageVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPCollectHistoryPageVC.h"
  9. #import "XLPageViewController.h"
  10. #import "KDPCollectHistoryVC.h"
  11. @interface KDPCollectHistoryPageVC ()<XLPageViewControllerDelegate,XLPageViewControllerDataSrouce>
  12. {
  13. NSArray *titleArray;
  14. }
  15. @property (nonatomic, strong) XLPageViewController *pageVC;
  16. @end
  17. @implementation KDPCollectHistoryPageVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self setUpPageVc];
  21. self.navigationController.navigationBar.barTintColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:SCREEN_WIDTH];
  22. }
  23. - (void)setUpPageVc{
  24. self.navBar.hidden=YES;
  25. titleArray=@[@"收藏夹",@"浏览记录"];
  26. [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleDefault;
  27. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, KDStatusHeight, 0, 0)];
  28. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  29. [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
  30. self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:returnBtn];
  31. XLPageViewControllerConfig *config = [[XLPageViewControllerConfig alloc] init];
  32. //标题间距
  33. config.titleSpace = 25;
  34. config.titleViewStyle = XLPageTitleViewStyleBasic;
  35. //标题高度
  36. config.titleViewHeight = 40;
  37. //标题选中颜色
  38. config.titleSelectedColor = [UIColor whiteColor];
  39. //标题选中字体
  40. config.titleSelectedFont = [UIFont fontWithName:@"PingFang-SC-Medium" size: 17];
  41. //标题正常颜色
  42. config.titleNormalColor = [UIColor whiteColor];
  43. //标题正常字体
  44. config.titleNormalFont = [UIFont fontWithName:@"PingFang-SC-Medium" size: 14];
  45. config.titleViewInset = UIEdgeInsetsMake(0, 10, 0, 10);
  46. //阴影颜色
  47. config.shadowLineColor = [UIColor whiteColor];
  48. //阴影宽度
  49. config.shadowLineWidth = 24;
  50. //阴影末端是直角
  51. config.shadowLineCap = XLPageShadowLineCapSquare;
  52. //分割线颜色
  53. config.separatorLineHidden = YES;
  54. config.shadowLineHeight = 3;
  55. config.showTitleInNavigationBar=YES;
  56. config.shadowLineAnimationType = XLPageShadowLineAnimationTypeZoom;
  57. config.titleViewAlignment=XLPageTitleViewAlignmentCenter;
  58. // config.navHeight=KDNavBarHeight;
  59. // config.contentHeight=SCREEN_HEIGHT-KDNavBarHeight;
  60. self.pageVC = [[XLPageViewController alloc] initWithConfig:config];
  61. self.pageVC.view.bounds = CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT);
  62. self.pageVC.delegate = self;
  63. self.pageVC.dataSource = self;
  64. [self addChildViewController:self.pageVC];
  65. [self.view addSubview:self.pageVC.view];
  66. }
  67. -(void)returnClickBtn
  68. {
  69. [self.navigationController popViewControllerAnimated:YES];
  70. }
  71. #pragma mark - XLPageViewController datasource and delegate
  72. - (NSInteger)pageViewControllerNumberOfPage{
  73. return titleArray.count;
  74. }
  75. - (NSString *)pageViewController:(XLPageViewController *)pageViewController titleForIndex:(NSInteger)index{
  76. return titleArray[index];
  77. }
  78. - (void)pageViewController:(XLPageViewController *)pageViewController didSelectedAtIndex:(NSInteger)index{
  79. NSLog(@"%ld",index);
  80. }
  81. - (UIViewController *)pageViewController:(XLPageViewController *)pageViewController viewControllerForIndex:(NSInteger)index{
  82. KDPCollectHistoryVC *contentVC = [[KDPCollectHistoryVC alloc] init];
  83. contentVC.pagetype=titleArray[index];
  84. return contentVC;
  85. }
  86. -(void)viewWillAppear:(BOOL)animated
  87. {
  88. [super viewWillAppear:animated];
  89. self.navigationController.navigationBar.hidden=NO;
  90. [UIApplication sharedApplication].statusBarStyle=UIStatusBarStyleLightContent;
  91. self.tabBarController.tabBar.hidden=YES;
  92. }
  93. -(void)viewWillDisappear:(BOOL)animated
  94. {
  95. [super viewWillDisappear:animated];
  96. self.tabBarController.tabBar.hidden=NO;
  97. self.navigationController.navigationBar.hidden=NO;
  98. self.view.frame=[UIScreen mainScreen].bounds;
  99. }
  100. @end