口袋优选

KBBuyLimitMainController.m 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // KBBuyLimitMainController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/6.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBBuyLimitMainController.h"
  9. #import "BuyLimitHeader.h"
  10. #import "KBChildBuyLimitController.h"
  11. #import "BuyLimitSegmentManager.h"
  12. #import "DateManager.h"
  13. #import "DateModel.h"
  14. @interface KBBuyLimitMainController ()
  15. @property (nonatomic, strong) BuyLimitHeader *titleView;
  16. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  17. @property (nonatomic, strong) NSMutableArray *vcList;
  18. @property (nonatomic, strong) NSArray *modelArr;
  19. @end
  20. @implementation KBBuyLimitMainController
  21. - (void)viewWillAppear:(BOOL)animated {
  22. [super viewWillAppear:animated];
  23. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. [self configNavigationBar];
  28. [self configDateAndTitles];
  29. }
  30. - (void)configNavigationBar {
  31. [self.navigationBar setNavTitle:@"限时抢购"];
  32. self.navigationBar.backgroundColor = [UIColor YHColorWithHex:0x3F3D39];
  33. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  34. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  35. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  36. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  37. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  38. }
  39. - (void)backAction {
  40. [self.navigationController popViewControllerAnimated:YES];
  41. }
  42. - (void)configDateAndTitles {
  43. NSArray *arr = [DateManager getBuyLimitDateModels];
  44. [self configHeaderAndPage:arr];
  45. }
  46. - (void)configHeaderAndPage:(NSArray *)modelArr {
  47. self.view.backgroundColor = [UIColor whiteColor];
  48. NSMutableArray *titles = [NSMutableArray array];
  49. NSMutableArray *subTitles = [NSMutableArray array];
  50. NSInteger showIndex = modelArr.count/2>0?modelArr.count/2:0;
  51. for (int i = 0; i < modelArr.count; i++) {
  52. DateModel *model = [modelArr objectAtIndex:i];
  53. [titles addObject:model.startTimeStr];
  54. KBChildBuyLimitController *child = [[KBChildBuyLimitController alloc] init];
  55. child.start_time = model.startDateStr;
  56. child.end_time = model.endDateStr;
  57. [self.vcList addObject:child];
  58. NSString *subTitle = i<=showIndex?@"已开抢":@"即将开场";
  59. child.canBuy = i<=showIndex?YES:NO;
  60. [subTitles addObject:subTitle];
  61. }
  62. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+55, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-55) vcOrViews:self.vcList];
  63. self.segScroll.bounces = NO;
  64. self.titleView = [[BuyLimitHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 55) titles:titles headStyle:BuyLimitHeadStyleSlide layoutStyle:BuyLimitLayoutDefault];
  65. self.titleView.subTitles = subTitles;
  66. self.titleView.showIndex = showIndex;
  67. self.titleView.slideHeight = 30;
  68. self.titleView.headColor = [UIColor YHColorWithHex:0x3F3D39];
  69. self.titleView.slideColor = [UIColor homeRedColor];
  70. self.titleView.selectColor = [UIColor whiteColor];
  71. self.titleView.deSelectColor = [UIColor whiteColor];
  72. self.titleView.bottomLineHeight = 0;
  73. [BuyLimitSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  74. [self.view addSubview:self.titleView];
  75. [self.view addSubview:self.segScroll];
  76. }];
  77. }
  78. - (NSMutableArray *)vcList {
  79. if (!_vcList) {
  80. _vcList = [NSMutableArray array];
  81. }
  82. return _vcList;
  83. }
  84. - (void)didReceiveMemoryWarning {
  85. [super didReceiveMemoryWarning];
  86. // Dispose of any resources that can be recreated.
  87. }
  88. /*
  89. #pragma mark - Navigation
  90. // In a storyboard-based application, you will often want to do a little preparation before navigation
  91. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  92. // Get the new view controller using [segue destinationViewController].
  93. // Pass the selected object to the new view controller.
  94. }
  95. */
  96. @end