Skip to content
Updating UINavigationController's appearance more easily.
Objective-C Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DoubleNavigationController [fix] navigation bar ui Apr 12, 2019
Example
Resource [chore] picture design Apr 12, 2019
.gitignore initial commit Nov 13, 2018
.travis.yml Initial commit Nov 12, 2018
DoubleNavigationController.podspec
LICENSE Initial commit Nov 12, 2018
README-zhCN.md [chore] readme Apr 12, 2019
README.md
_Pods.xcodeproj

README.md

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.

You can’t perform that action at this time.