123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- //
- // LDCollectionViewController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/1/24.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDCollectionViewController.h"
- #import "LDTypeButtonHeader.h"
- #import "LDCollectionTicketController.h"
- #import "LDCollectionGoodsController.h"
- #import "MLMSegmentHead.h"
- #import "MLMSegmentManager.h"
- @interface LDCollectionViewController ()<UIScrollViewDelegate,MLMSegmentHeadDelegate>
- @property (nonatomic, strong) UIScrollView *scrollView;
- @property (nonatomic, strong) MLMSegmentHead *titleView;
- @property (nonatomic, strong) NSArray *childVCArr;
- @property (nonatomic, assign) NSInteger currentIndex;
- @end
- @implementation LDCollectionViewController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self.view bringSubviewToFront:self.navigationBar];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configNavigtionBar];
- [self configChildViewController];
- }
- - (void)configNavigtionBar {
-
- // UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- // [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
- // [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- // [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- self.navigationBar.showNavigationBarBottomLine = YES;
-
- NSArray *list = @[@"收藏的券",@"收藏的商品"];
- self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(50, NavBarHeight-44, SCREEN_WIDTH-100, 44) titles:list headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutCenter];
- self.titleView.headColor = [UIColor clearColor];
- self.titleView.fontScale = 1;
- self.titleView.fontSize = 14;
- self.titleView.lineScale = .8;
- self.titleView.equalSize = YES;
- self.titleView.bottomLineHeight = 0;
- self.titleView.lineColor = [UIColor homeRedColor];
- self.titleView.delegate = self;
- self.titleView.selectColor = [UIColor homeRedColor];
- self.titleView.deSelectColor = [UIColor YHColorWithHex:0x666666];
- [MLMSegmentManager associateHead:self.titleView withScroll:nil completion:^{
- [self.navigationBar addSubview:self.titleView];
- self.titleView.centerX = self.navigationBar.centerX;
- }];
-
- }
- - (void)configChildViewController {
-
- LDCollectionTicketController *ticket = [[LDCollectionTicketController alloc] init];
- [self.view addSubview:ticket.view];
- [self addChildViewController:ticket];
- ticket.view.y = NavBarHeight;
-
- LDCollectionGoodsController *goods = [[LDCollectionGoodsController alloc] init];
- [self.view insertSubview:goods.view belowSubview:ticket.view];
- [self addChildViewController:goods];
- goods.view.y = NavBarHeight;
- self.currentIndex = 0;
- self.childVCArr = @[ticket,goods];
-
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark --------------------- MLMSegmentHeadDelegate ---------
- - (void)didSelectedIndex:(NSInteger)index {
- [self transitionFromViewController:self.childVCArr[self.currentIndex] toViewController:self.childVCArr[index] duration:0.3 options:UIViewAnimationOptionCurveEaseOut animations:nil completion:^(BOOL finished) {
- self.currentIndex = index;
- }];
- }
- #pragma mark ------
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
- _scrollView.delegate = self;
- _scrollView.pagingEnabled = YES;
-
- }
- return _scrollView;
- }
- - (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
|