Skip to content

A Custom Push Navigation Controller

License

Notifications You must be signed in to change notification settings

kyleYang/KYFlipNavigationController

Repository files navigation

KYFlipNavigationController

CI StatusVersionLicensePlatform

The KYFlipNavigationController is an custom NavigationController the use UIViewController to manager the UIViewController(include UINavigationController,UITabbarController,UIViewController) like the UINavigationController . Many app like EasyNet News and Toutiao use TabbarController UINavigationController when push

##Overview alt tag

Usage

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

Init

Set up flipNavigationController as root of a window,self.flipNavigationController will find the KYFlipNavigationController if it's exist!

letfirstVC=FirstViewController(nibName:nil, bundle:nil); firstVC.title ="First"letfirstNavi=UINavigationController(rootViewController: firstVC)letsencondVC=SecondViewController(nibName:nil, bundle:nil); sencondVC.title ="Second"lettabbar=RDVTabBarController() tabbar.viewControllers =[firstNavi,sencondVC]letflipViewController=KYFlipNavigationController(rootViewCotroller: tabbar)self.window =UIWindow(); self.window?.backgroundColor =UIColor.white; self.window?.rootViewController = flipViewController; self.window?.makeKeyAndVisible()

Push or Pop

Push and pop almost like the UINavigationController . The key way is to find the flipNavigationController. It's easy that we use a UIViewController's extension

 //Push letviewController=ThirdViewController(nibName:nil, bundle:nil) viewController.title ="cell_\(indexPath.row)" // push a navigationcontroller letnavi=UINavigationController(rootViewController: viewController)self.rdv_tabBarController.flipNavigationController?.pushViewController(navi, animated:true)//self is add to a tabbarcontroller //we also an push a UIViewController,and if self is not add to a tabbarcontroller self.flipNavigationController?.pushViewController(viewController, animated:true) //Pop self.flipNavigationController?.popViewController(true) //also we can pop to a viewcontroller or to the rootviewcontroller

The public func

 //Push pushViewController(_ viewController : UIViewController, animated : Bool, completed : KYFlipNavigationCompletionBlock?=nil) //Pop publicfunc popViewController(_ animated :Bool, completed :KYFlipNavigationCompletionBlock?=nil) public func popToViewController(_ viewController :UIViewController, animated :Bool, completed :KYFlipNavigationCompletionBlock?=nil) public func popToRootViewControllerAnimated(_ animated :Bool,completed :KYFlipNavigationCompletionBlock?)

Change the stack

You can also change the UIViewController stack when you want,so you can remove some viewcontroller or add some viewcontroller from the stack and change the pop way

guardlet viewControllers =self.flipNavigationController?.viewControllers else{return}varnewControllers:Array<UIViewController>=[]forviewControllerin viewControllers {if !viewController.isKindOfClass(ForthViewController.self){ newControllers.append(viewController)}}self.flipNavigationController?.viewControllers = newControllers

Requirements

Installation

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

pod"KYFlipNavigationController"

Author

kyleYang, [email protected]

If you find any porblem , please tell me

License

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

About

A Custom Push Navigation Controller

Resources

License

Stars

Watchers

Forks

Packages

No packages published