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
To run the example project, clone the repo, and run pod install
from the Example directory first.
Set up flipNavigationController as root of a window,self.flipNavigationController will find the KYFlipNavigationController if it's exist!
let firstVC = FirstViewController(nibName: nil, bundle: nil);
firstVC.title = "First"
let firstNavi = UINavigationController(rootViewController: firstVC)
let sencondVC = SecondViewController(nibName: nil, bundle: nil);
sencondVC.title = "Second"
let tabbar = RDVTabBarController()
tabbar.viewControllers = [firstNavi,sencondVC]
let flipViewController = KYFlipNavigationController(rootViewCotroller: tabbar)
self.window = UIWindow();
self.window?.backgroundColor = UIColor.white;
self.window?.rootViewController = flipViewController;
self.window?.makeKeyAndVisible()
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
let viewController = ThirdViewController(nibName: nil, bundle: nil)
viewController.title = "cell_\(indexPath.row)"
// push a navigationcontroller
let navi = 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
//Push
pushViewController(_ viewController : UIViewController, animated : Bool, completed : KYFlipNavigationCompletionBlock? = nil)
//Pop
public func popViewController(_ animated : Bool, completed : KYFlipNavigationCompletionBlock? = nil)
public func popToViewController(_ viewController : UIViewController, animated : Bool, completed : KYFlipNavigationCompletionBlock? = nil)
public func popToRootViewControllerAnimated(_ animated : Bool ,completed : KYFlipNavigationCompletionBlock?)
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
guard let viewControllers = self.flipNavigationController?.viewControllers else {
return
}
var newControllers : Array<UIViewController> = []
for viewController in viewControllers {
if !viewController.isKindOfClass(ForthViewController.self) {
newControllers.append(viewController)
}
}
self.flipNavigationController?.viewControllers = newControllers
KYFlipNavigationController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "KYFlipNavigationController"
kyleYang, yangzychina@gmail.com
If you find any porblem , please tell me
KYFlipNavigationController is available under the MIT license. See the LICENSE file for more info.