Coder Social home page Coder Social logo

zwznavigationcontrollerdemo's Introduction

ZWZNavigationControllerDemo

Custom UINavigationController subclass which allows animated transitions on navigation bar background color.

ZWZNavigationControllerDemo Animation

Usage

Storyboard

If you've set up a Navigation Controller in your Storyboard, you'll need to specify ZWZNavigationBar as the custom class for the Navigation Bar in your Navigation Controller scene.

Programmatically

If you're initializing your Navigation Controller programmatically, you'll need to use the initWithNavigationBarClass:toolbarClass: initializer, passing [ZWZNavigationBar class] for the *navigationBarClass* parameter.

You'll need to import ZWZNavigationController.h when you want to change navigation bar background color, as described below.

Configuration

The best place to set navigation bar background color for a view controller is the view controller's 'viewDidLoad:' method

- (void)viewDidLoad {
    [super viewDidLoad];
    [(ZWZNavigationController *)self.navigationController setNavigationBarBackgroudColor:[UIColor colorWithRed:arc4random_uniform(255)/255.0
                                                                                                         green:arc4random_uniform(255)/255.0
                                                                                                          blue:arc4random_uniform(255)/255.0
                                                                                                         alpha:1]
                                                                       forViewController:self];
}

If you want to change the navigation bar background color after view did appeared, use the 'setBarBackgroundColor:animationDuration:options:usingSpring:'

Animated:

    ZWZNavigationController *nvc = (ZWZNavigationController *)self.navigationController;
    [nvc.zwzNavigationBar setBarBackgroundColor:color
                              animationDuration:0.35
                                        options:UIViewAnimationOptionCurveEaseInOut
                                    usingSpring:NO];

Not Animated:

    ZWZNavigationController *nvc = (ZWZNavigationController *)self.navigationController;
    [nvc.zwzNavigationBar setBarBackgroundColor:color
                              animationDuration:0
                                        options:0
                                    usingSpring:NO];

About

WenZheng Zhang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.