All Projects → Jerry0523 → NavigationBarHelper

Jerry0523 / NavigationBarHelper

Licence: MIT license
A library that helps to manage the navigation bar style. It helps to remember bar attributes between different VCs and keep the transition smooth.

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to NavigationBarHelper

RRNavigationBar
bring UINavigationBar to UIViewController.
Stars: ✭ 11 (-42.11%)
Mutual labels:  navigationbar-transition
Kmnavigationbartransition
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.
Stars: ✭ 3,274 (+17131.58%)
Mutual labels:  navigationbar-transition

Build Status

NavigationBarHelper

A library that helps to manage the navigation bar style. It helps to remember bar attributes between different VCs and keep the transition smooth.

alt tag

Usage

When your app finishes launch, call the function below to start up the helper.

NavigationBarHelper.load()

swizzle UIViewController.viewSafeAreaInsetsDidChange

swizzle UIViewController.viewWillLayoutSubviews

swizzle UIViewController.viewWillAppear(_:)

UINavigationBar.hitTest(_:with:)

For a viewController, use the function below to modify the navigation bar.

override func viewDidLoad() {
    super.viewDidLoad()
    barBackgroundHelper.perform {
        //Codes for navigation bar update.
        //e.g. $0.tintColor = UIColor.white
    }
}

After calling the function above, any attribute (background image/tintColor/barTintColor/barStyle etc) will be remembered by the library. It will create a mirror background view of the navigation bar (auto managed) and clear the bar background (to provide a smooth transition). Any change to the navigation bar background (background image/barTintColor/barStyle/shadowImage) in the closure will be syncronized with the mirror view.

Protocol NavigationBarHelperDelegate

  • willRestore(backgroundAttr: inout NavigationBarHelper.BackgroundAttr)

Called before the mirror view capturing the bar's background attribute. Modify the backgroundAttr if it is not your appetite.

  • didRestore(backgroundAttr: NavigationBarHelper.BackgroundAttr)

Called after the mirror view capturing the bar's background attribute. It is the best time for you to do additional change to the bar's background attr. After this function is called, the mirror background view will synchronize with the bar's background.

  • willRestore(foregroundAttr: inout NavigationBarHelper.ForegroundAttr)

Called before the navigation bar's foreground attribute being restored, especially when the viewController's appearing. Modify the foregroundAttr if it is not your appetite.

  • didRestore(foregroundAttr: NavigationBarHelper.ForegroundAttr)

Called after the navigation bar's foreground attribute being restored, especially when the viewController's appearing. Do additional change if you have modified the navigation bar out of the performNavigationBarUpdates scope.(e.g, you have set the bar tint color according to scrollview offset).

License

(MIT license)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].