Skip to content

Instantly share code, notes, and snippets.

View lastcc's full-sized avatar
😀
Fantastic!

cc lastcc

😀
Fantastic!
  • LAIX Inc.
View GitHub Profile
@lastcc
lastcc / isAnimatingToNavigationStack.swift
Created December 24, 2017 10:01
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