SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller.
ManiacDev.com referred.
https://maniacdev.com/2015/03/open-source-component-enhancing-the-back-button-with-view-history-navigation
- iOS task manager like UI
- Launch Navigation History with Long tap action of Back Bar Button
- Support Swift2.0
- Support 3D Touch
SAHistoryNavigationViewController is available through CocoaPods. If you have cocoapods 0.38.0 or greater, you can install it, simply add the following line to your Podfile:
pod "SAHistoryNavigationViewController"
Add the SAHistoryNavigationViewController directory to your project.
If you install from cocoapods, You have to write import SAHistoryNavigationViewController
.
Set custom class of UINavigationController to SAHistoryNavigationViewController. In addition, set module to SAHistoryNavigationViewController.
You can use SAHistoryNavigationViewController as self.navigationController
in ViewController, bacause implemented extension UINavigationController
as below codes and override those methods in SAHistoryNavigationViewController.
extension UINavigationController {
public weak var navigationDelegate: SAHistoryNavigationViewControllerDelegate? {
set {
willSetNavigationDelegate(navigationDelegate)
}
get {
return willGetNavigationDelegate()
}
}
public weak var transitionDelegate: SAHistoryNavigationViewControllerTransitionDelegate? {
set {
willSetTransitionDelegate(transitionDelegate)
}
get {
return willGetTransitionDelegate()
}
}
public var interactivePopGestureEnabled: Bool {
set {
willSetInteractivePopGestureEnabled(newValue)
}
get {
return willGetInteractivePopGestureEnabled()
}
}
public func showHistory() {}
public func setHistoryBackgroundColor(color: UIColor) {}
public func contentView() -> UIView? { return nil }
func willSetNavigationDelegate(navigationDelegate: SAHistoryNavigationViewControllerDelegate?) {}
func willGetNavigationDelegate() -> SAHistoryNavigationViewControllerDelegate? { return nil }
func willSetNavigationTransitioningDelegate(navigationTransitioningDelegate: SAHistoryNavigationViewControllerTransitioningDelegate?) {}
func willGetNavigationTransitioningDelegate() -> SAHistoryNavigationViewControllerTransitioningDelegate? { return nil }
func willSetInteractivePopGestureEnabled(interactivePopGestureEnabled: Bool) {}
func willGetInteractivePopGestureEnabled() -> Bool { return true }
}
And you have to initialize like this.
let ViewController = UIViewController()
let navigationController = SAHistoryNavigationViewController()
navigationController.setViewControllers([ViewController], animated: true)
presentViewController(navigationController, animated: true, completion: nil)
If you want to launch Navigation History without long tap action, use this code.
navigationController?.showHistory()
If you want to customize background of Navigation History, you can use those methods.
navigationController?.contentView()
navigationController?.setHistoryBackgroundColor(color: UIColor)
This is delegate methods.
@objc public protocol SAHistoryNavigationViewControllerDelegate : NSObjectProtocol {
optional func navigationController(navigationController: SAHistoryNavigationViewController, willShowViewController viewController: UIViewController, animated: Bool)
optional func navigationController(navigationController: SAHistoryNavigationViewController, didShowViewController viewController: UIViewController, animated: Bool)
optional func navigationControllerSupportedInterfaceOrientations(navigationController: SAHistoryNavigationViewController) -> UIInterfaceOrientationMask
optional func navigationControllerPreferredInterfaceOrientationForPresentation(navigationController: SAHistoryNavigationViewController) -> UIInterfaceOrientation
optional func navigationController(navigationController: SAHistoryNavigationViewController, willHandleEdgeSwipe gesture: UIScreenEdgePanGestureRecognizer)
optional func navigationController(navigationController: SAHistoryNavigationViewController, didHandleEdgeSwipe gesture: UIScreenEdgePanGestureRecognizer)
}
@objc public protocol SAHistoryNavigationViewControllerTransitioningDelegate : NSObjectProtocol {
optional func navigationController(navigationController: SAHistoryNavigationViewController, interactionControllerForAnimationController animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning?
optional func navigationController(navigationController: SAHistoryNavigationViewController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
}
- Xcode 7.0 or greater
- iOS7.0(manually only) or greater
Taiki Suzuki, [email protected]
SAHistoryNavigationViewController is available under the MIT license. See the LICENSE file for more info.