// // VipLessonViewController.m // jiaPei // // Created by 张嵘 on 2019/6/26. // Copyright © 2019 JCZ. All rights reserved. // #import "VipLessonViewController.h" #import "VipLessonTableHeaderView.h" #import "VipLessonContentViewController.h" @interface VipLessonViewController () @end @implementation VipLessonViewController #pragma mark - Life Circle - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; NSFileManager*fileManager =[NSFileManager defaultManager]; NSError*error; if( [fileManager fileExistsAtPath:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"dyhapp.db"]]]== NO){ NSString*resourcePath =[[NSBundle mainBundle] pathForResource:@"dyhapp" ofType:@"db"]; [fileManager copyItemAtPath:resourcePath toPath:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"dyhapp.db"]] error:&error]; } } #pragma mark - Public Function + (instancetype)suspendCenterPageVC { YNPageConfigration *configration = [YNPageConfigration defaultConfig]; configration.pageStyle = YNPageStyleSuspensionTopPause; configration.headerViewCouldScale = YES; configration.headerViewScaleMode = YNPageHeaderViewScaleModeTop; configration.showNavigation = YES; configration.scrollMenu = NO; configration.aligmentModeCenter = NO; /// Item configration.selectedItemColor = UIColor.blackColor; configration.normalItemColor = UIColor.lightGrayColor; configration.itemFont = [UIFont systemFontOfSize:17]; configration.selectedItemFont = [UIFont systemFontOfSize:17]; /// bottomLine configration.showBottomLine = YES; configration.bottomLineBgColor = UIColor.groupTableViewBackgroundColor; configration.bottomLineHeight = .5; /// line configration.lineColor = defGreen; configration.lineHeight = 3; configration.lineWidthEqualFontWidth = true; return [self suspendCenterPageVCWithConfig:configration]; } + (NSArray *)getArrayVCs { VipLessonContentViewController *firstVC = [[VipLessonContentViewController alloc] init]; VipLessonContentViewController *secondVC = [[VipLessonContentViewController alloc] init]; return @[firstVC, secondVC]; } + (NSArray *)getArrayTitles { return @[@"科目一", @"科目四"]; } + (instancetype)suspendCenterPageVCWithConfig:(YNPageConfigration *)config { VipLessonViewController *vc = [VipLessonViewController pageViewControllerWithControllers:[self getArrayVCs] titles:[self getArrayTitles] config:config]; vc.dataSource = vc; vc.delegate = vc; // VipLessonTableHeaderView *headerView = [[NSBundle mainBundle] loadNibNamed:@"VipLessonTableHeaderView" owner:self options:nil].firstObject; // [RACObserve(headerView.notVipView, hidden) subscribeNext:^(id x) { // if (headerView.notVipView.hidden) { // headerView.frame = CGRectMake(0, 0, kScreenWidth, kScreenWidth * 0.53); // }else { // headerView.frame = CGRectMake(0, 0, kScreenWidth, kScreenWidth * (737.f / 1080.f)); // } // vc.headerView = headerView; // [vc reloadSuspendHeaderViewFrame]; // }]; /// 指定默认选择index 页面 vc.pageIndex = 0; return vc; } #pragma mark - Private Functions - (void)initUI { /// 导航栏设置 self.title = @"VIP课程"; [self configNavigationBar]; } #pragma mark - YNPageViewControllerDataSource - (UIScrollView *)pageViewController:(YNPageViewController *)pageViewController pageForIndex:(NSInteger)index { UIViewController *vc = pageViewController.controllersM[index]; if ([vc isKindOfClass:[VipLessonContentViewController class]]) { return [(VipLessonContentViewController *)vc collectionView]; }else { return nil; } } #pragma mark - YNPageViewControllerDelegate - (void)pageViewController:(YNPageViewController *)pageViewController contentOffsetY:(CGFloat)contentOffset progress:(CGFloat)progress { // NSLog(@"--- contentOffset = %f, progress = %f", contentOffset, progress); } /// 返回列表的高度 默认是控制器的高度大小 - (CGFloat)pageViewController:(YNPageViewController *)pageViewController heightForScrollViewAtIndex:(NSInteger)index { return kScreenHeight + (kScreenWidth * 0.53) + kScreenHeight; } - (void)pageViewController:(YNPageViewController *)pageViewController didScrollMenuItem:(UIButton *)itemButton index:(NSInteger)index { NSLog(@"didScrollMenuItem index %ld", index); } @end