DoubleNavigationController 0.9.0

DoubleNavigationController 0.9.0

Maintained by Yao Li.



  • By
  • yao.li

DoubleNavigationController

Platform Version License MIT Gmail

Introduction

中文文档

As we all known, UINavigationController is a container view controller that manages one or more child view controllers in a navigation interface. Sometimes, we just wanna update the appearance in current view controller instead of affecting the whole app. DoubleNavigationController is a library that can solve the problem above.

Architecture

We can think of UINavigationController as a tree, and each node is a ViewController that managed by it. By using DoubleNavigationController, we can update the appearance of NavigationBar in current node without affecting its parent node's. However, its child nodes' NavigationBar will be affected. The relationship can be described as the picture below.

Example

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Example

Usage

You can customize your navigation by implementing dbn_configNavigationController: in your ViewVontroller.

- (void)dbn_configNavigationController:(UINavigationController *)navigationController {
    [navigationController setNavigationBarHidden:NO animated:NO];
    navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    navigationController.navigationBar.tintColor = [UIColor purpleColor];
    navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:20], NSForegroundColorAttributeName: [UIColor redColor]};
}

- (void)dbn_configNavigationItem:(UINavigationItem *)navigationItem {
    UIBarButtonItem *btnItem = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStylePlain target:self action:@selector(eventFromButton:)];
    navigationItem.rightBarButtonItem = btnItem;
    navigationItem.title = @"Hello";
}

You can also update the appearance of your app's navigation at any time by using dbn_performBatchUpdates: in the category of UIViewController.

[self dbn_performBatchUpdates:^(UINavigationController * _Nullable navigationController) {
    if (navigationController) {
        navigationController.navigationBar.tintColor = [UIColor purpleColor];
    }
}];

Installation

DoubleNavigationController is available through CocoaPods. To install it, simply add the following line to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'DoubleNavigationController'
end

License

DoubleNavigationController is available under the MIT license. See the LICENSE file for more info.