123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- //
- // KBBuyLimitMainController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/6.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBBuyLimitMainController.h"
- #import "BuyLimitHeader.h"
- #import "KBChildBuyLimitController.h"
- #import "BuyLimitSegmentManager.h"
- #import "DateManager.h"
- #import "DateModel.h"
- @interface KBBuyLimitMainController ()
- @property (nonatomic, strong) BuyLimitHeader *titleView;
- @property (nonatomic, strong) MLMSegmentScroll *segScroll;
- @property (nonatomic, strong) NSMutableArray *vcList;
- @property (nonatomic, strong) NSArray *modelArr;
- @end
- @implementation KBBuyLimitMainController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configNavigationBar];
- [self configDateAndTitles];
- }
- - (void)configNavigationBar {
- [self.navigationBar setNavTitle:@"限时抢购"];
- self.navigationBar.backgroundColor = [UIColor YHColorWithHex:0x3F3D39];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)configDateAndTitles {
-
- NSArray *arr = [DateManager getBuyLimitDateModels];
- [self configHeaderAndPage:arr];
- }
- - (void)configHeaderAndPage:(NSArray *)modelArr {
- self.view.backgroundColor = [UIColor whiteColor];
-
- NSMutableArray *titles = [NSMutableArray array];
- NSMutableArray *subTitles = [NSMutableArray array];
- NSInteger showIndex = modelArr.count/2>0?modelArr.count/2:0;
- for (int i = 0; i < modelArr.count; i++) {
- DateModel *model = [modelArr objectAtIndex:i];
- [titles addObject:model.startTimeStr];
- KBChildBuyLimitController *child = [[KBChildBuyLimitController alloc] init];
- child.start_time = model.startDateStr;
- child.end_time = model.endDateStr;
- [self.vcList addObject:child];
-
- NSString *subTitle = i<=showIndex?@"已开抢":@"即将开场";
- child.canBuy = i<=showIndex?YES:NO;
- [subTitles addObject:subTitle];
- }
- self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight+55, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-55) vcOrViews:self.vcList];
- self.segScroll.bounces = NO;
- self.titleView = [[BuyLimitHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, 55) titles:titles headStyle:BuyLimitHeadStyleSlide layoutStyle:BuyLimitLayoutDefault];
- self.titleView.subTitles = subTitles;
- self.titleView.showIndex = showIndex;
- self.titleView.slideHeight = 30;
- self.titleView.headColor = [UIColor YHColorWithHex:0x3F3D39];
- self.titleView.slideColor = [UIColor homeRedColor];
- self.titleView.selectColor = [UIColor whiteColor];
- self.titleView.deSelectColor = [UIColor whiteColor];
- self.titleView.bottomLineHeight = 0;
- [BuyLimitSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
- [self.view addSubview:self.titleView];
- [self.view addSubview:self.segScroll];
- }];
- }
- - (NSMutableArray *)vcList {
- if (!_vcList) {
- _vcList = [NSMutableArray array];
- }
- return _vcList;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|