Today we'll look at a fun and interesting library that can help improve how users navigate around in our apps.
It comes to us from Taiki Suzuki and it's called SAHistoryNavigationViewController.
It works by augmenting UINavigationController's traditional interactions to add a gesture to view each of the view controller's that have been pushed on to it. We can use it just like a regular navigation controller:
let vc = SpaceshipsViewController()
let nc = SAHistoryNavigationViewController(rootViewController: vc)
presentViewController(nc, animated: true, completion: nil)
The library will handle showing the history scroll view when the user long presses the back button. If the user's device supports 3D Touch, the history scroll view activate with that gesture instead.
We can also trigger the history view to be shown at anytime like this:
navigationController?.showHistory()
We can customize the background color shown behind all the βzoomed outβ view controller easily:
navigationController?.setHistoryBackgroundColor(.blackColor())
We can also customize the background view by subclassing, and overriding the contentView
function.
More info about SAHistoryNavigationViewController can be found at git.io/historync