title: Custom segue transition animation
body: <p>I'm working on an app that utilizes the navigation controller. I have a certain view controller that has a left and right button in the navigation bar and each button segues to a different view controller. When I press the right button, I just call <code>self.performSegue(withIdentifier: "ToDestination", sender: nil)</code> and when I pop back I call <code>_ = self.navigationController?.popViewController(animated: true)</code>. </p>
  
  <p>My issue is when I press the left button. I can push and pop, but I want the transition to work opposite of the right button. Since I'm pressing the left button, I want the segue to transition from left to right, and when I pop, I want the segue to transition from right to left. </p>
  
  <p>I can get the transitions to work the way I want by doing:</p>
  
  <pre><code>//push
  let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "SearchController") as! SearchController
  let transition: CATransition = CATransition()
  let timeFunc : CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
  transition.duration = 0.5
  transition.timingFunction = timeFunc
  transition.type = kCATransitionPush
  transition.subtype = kCATransitionFromLeft
  self.navigationController!.view.layer.add(transition, forKey: kCATransition)
  self.navigationController!.pushViewController(vc, animated: true)
  
  //pop
  let transition: CATransition = CATransition()
  let timeFunc : CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
  transition.duration = 0.5
  transition.timingFunction = timeFunc
  transition.type = kCATransitionPush
  transition.subtype = kCATransitionFromRight
  self.navigationController!.view.layer.add(transition, forKey: kCATransition)
  _ = self.navigationController?.popViewController(animated: true)
  </code></pre>
  
  <p>This works, but there is a black flash when transitioning between view controllers. Is there a better way to get the default transition animation?</p>