Skip to content

Instantly share code, notes, and snippets.

@lastcc
Created December 24, 2017 10:01
Show Gist options
  • Save lastcc/8dfdc25ee44388e3babc9290eae189cb to your computer and use it in GitHub Desktop.
Save lastcc/8dfdc25ee44388e3babc9290eae189cb to your computer and use it in GitHub Desktop.
Check if self is being pushed to navigation controller
private var isAnimatingToNavigationStack: Bool {
guard let transitionCoordinator = transitionCoordinator,
let viewControllers = navigationController?.viewControllers,
let from = transitionCoordinator.viewController(forKey: .from),
let to = transitionCoordinator.viewController(forKey: .to),
let indexOfFrom = viewControllers.index(of: from),
let indexOfTo = viewControllers.index(of: to)
else { return false }
return to == self && indexOfTo - 1 == indexOfFrom
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment