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
- iOS task manager like UI
- Launch Navigation History with Long tap action of Back Bar Button
- Support Swift2.0
- Support 3D Touch (If device is not supported 3D Touch, automatically replacing to long tap gesture.)
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 historyDelegate: SAHistoryNavigationViewControllerDelegate? {
set {
willSetHistoryDelegate(newValue)
}
get {
return willGetHistoryDelegate()
}
}
public func showHistory() {}
public func setHistoryBackgroundColor(color: UIColor) {}
public func contentView() -> UIView? { return nil }
func willSetHistoryDelegate(delegate: SAHistoryNavigationViewControllerDelegate?) {}
func willGetHistoryDelegate() -> SAHistoryNavigationViewControllerDelegate? { return nil }
}
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 historyControllerDidShowHistory(controller: SAHistoryNavigationViewController, viewController: UIViewController)
}
- Xcode 7.0 or greater
- iOS8.0 or greater
- MisterFusion
Taiki Suzuki, s1180183@gmail.com
SAHistoryNavigationViewController is available under the MIT license. See the LICENSE file for more info.