NZHSwipeNavigationPageController 1.5.0

NZHSwipeNavigationPageController 1.5.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
Released最新发布2016年1月

iiyumewo 维护。



  • iiyumewo

NZHSwipeNavigationPageController 可以美观、简单地创建具有高度可定制性的导航栏。

安装

手动安装

  1. 下载所有 NZHSwipeNavigationPageController 文件。
  2. 将源文件文件夹添加到您的 Xcode 项目中。
  3. 使用 #import "NZHSwipeNavigationPageController" 包括您需要的任何地方。

功能

  • 作为多个控制器的容器。
  • 自动生成您可以在多种样式中选择的自定义导航栏。
  • 包含几种基本的页面选择器动画类型。
  • 导航栏中所有内容都可以高度自定义。

用法

NZHSwipeNavigationPageController 是一个控制器的容器,因此我们需要包含多个控制器、按钮标题和一些参数等的数组。

    UIViewController *demo1 = [[UIViewController alloc]init];
    UIViewController *demo2 = [[UIViewController alloc]init];
    UIViewController *demo3 = [[UIViewController alloc]init];
    UIViewController *demo4 = [[UIViewController alloc]init];
    UIViewController *demo5 = [[UIViewController alloc]init];
    demo1.view.backgroundColor = FLAT_ORANGE;
    demo2.view.backgroundColor = FLAT_ORANGERED;
    demo3.view.backgroundColor = FLAT_ROSERED;
    demo4.view.backgroundColor = FLAT_PURPLE;
    demo5.view.backgroundColor = FLAT_DARKPURPLE;

    NSArray *viewControllerArray = @[demo1, demo2, demo3, demo4, demo5];
    NSArray *buttonTextArray = @[@"Home", @"Fund", @"Topic", @"Industry", @"Market"];

onNavigation

    NZHSwipeNavigationPageController *barOnNavigationBarController = 
    [[NZHSwipeNavigationPageController alloc]initForSwipeByNavigationBarWithSubTitles:buttonTextArray 
                                                                       andControllers:viewControllerArray 
                                                                       andButtonWidth:70];

deafultPattern

    NZHSwipeNavigationPageController *deafultPatternController = 
    [[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision" 
                                                                andButtonTitles:buttonTextArray 
                                                                      barHeight:40 
                                                                    buttonWidth:70 
                                                                    controllers:viewControllerArray];

bottomSelector

    //an arbitrary view for custom selector.
    UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 8)];
    selectorView.backgroundColor = [UIColor redColor];
    selectorView.layer.cornerRadius = 6.0;
    selectorView.layer.opacity = 0.3;

    NZHSwipeNavigationPageController *customBottomSelectorController = 
    [[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision" 
                                                                andButtonTitles:buttonTextArray 
                                                                      barHeight:40 
                                                                    buttonWidth:70 
                                                                    controllers:viewControllerArray];
    [customBottomSelectorController setFlatAnimationalSelector:selectorView];

middleSelector

    //an arbitrary view for custom selector.
    UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 25)];
    selectorView.backgroundColor = [UIColor redColor];
    selectorView.layer.cornerRadius = 6.0;
    selectorView.layer.opacity = 0.3;

    NZHSwipeNavigationPageController *customMiddleSelectorController = 
    [[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision" 
                                                                andButtonTitles:buttonTextArray 
                                                                      barHeight:40 
                                                                    buttonWidth:70 
                                                                    controllers:viewControllerArray];
    [customMiddleSelectorController setMiddleAnimationalSelector:selectorView];

customAnimation

    //an arbitrary view for custom selector.
    UIView *selectorView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 60, 25)];
    selectorView.backgroundColor = [UIColor redColor];
    selectorView.layer.cornerRadius = 6.0;
    selectorView.layer.opacity = 0.3;

    NZHSwipeNavigationPageController *customAnimationSelectorController = 
    [[NZHSwipeNavigationPageController alloc]initForBarUnderNavigationWithTitle:@"Decision" 
                                                                andButtonTitles:buttonTextArray 
                                                                      barHeight:40 
                                                                    buttonWidth:70 
                                                                    controllers:viewControllerArray];
    [customAnimationSelectorController setMiddleAnimationalSelector:selectorView];

    /*
     * positionRatio is a float from 0 to 1 which is the progress between swiping from one button to another button next to.
     * you can change the shape of selector bwteen its changing period in this block.
     */
    __block NZHSwipeNavigationPageController *blockDemo = customAnimationSelectorController;
    customAnimationSelectorController.customAnimationBlock = ^(UIScrollView *pageScrollView) {
        CGFloat originSelectorHeight = 25;
        CGFloat changedSelectorHeight;
        if (blockDemo.positionRatio <= 0.5) {
            changedSelectorHeight = originSelectorHeight*(1-blockDemo.positionRatio);
        }else if (blockDemo.positionRatio > 0.5) {
            changedSelectorHeight = originSelectorHeight*blockDemo.positionRatio;
        }
        CGRect rect = CGRectMake(blockDemo.selectorX, blockDemo.selectorY, blockDemo.animationView.frame.size.width, changedSelectorHeight);
        blockDemo.animationView.frame = rect;
    };