TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Feb 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Taiki Suzuki.
Support 3D Touch for iOS9!!
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
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.sah.navigationController
in any ViewController, bacause implemented extension SAHistoryExtension
as below codes.
public protocol SAHistoryCompatible {
associatedtype CompatibleType
var sah: CompatibleType { get }
}
public extension SAHistoryCompatible {
public var sah: SAHistoryExtension<Self> {
return SAHistoryExtension(self)
}
}
public final class SAHistoryExtension<Base> {
public let base: Base
public init(_ base: Base) {
self.base = base
}
}
extension UIViewController: SAHistoryCompatible {}
extension SAHistoryExtension where Base: UIViewController {
public var navigationController: SAHistoryNavigationViewController? {
return base.navigationController as? SAHistoryNavigationViewController
}
}
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.
//In any UIViewController
self.sah.navigationController?.showHistory()
If you want to customize background of Navigation History, you can use those methods.
//In any UIViewController
self.sah.navigationController?.contentView
self.sah.navigationController?.historyBackgroundColor
This is delegate methods.
@objc public protocol SAHistoryNavigationViewControllerDelegate: NSObjectProtocol {
optional func historyControllerDidShowHistory(controller: SAHistoryNavigationViewController, viewController: UIViewController)
}
Taiki Suzuki, [email protected]
SAHistoryNavigationViewController is available under the MIT license. See the LICENSE file for more info.