title: ViewController slide animation
body: <p>I want to create an animation like the <strong>iOS app facebook at tabswitch</strong><sup>[1]</sup>. I have already tried to develop some kind of animation, the problem that occurs is that the old view controller becomes invisible directly on the switch, instead of fading out slowly while the new controller is sliding in fast.</p>
  
  <p>I've found this SO question <a href="https://stackoverflow.com/questions/44346280/how-to-animate-tab-bar-tab-switch-with-a-crossdissolve-slide-transition">How to animate Tab bar tab switch with a CrossDissolve slide transition?</a> but the as correct marked solution does not really work for me (it is not a slide it is a fade transition). What I'd also like to get is the function to make slide left or right to switch the tabs. Like it was on a older version of facebook.</p>
  
  <p>What I've got so far is this:</p>
  
  <pre><code>extension TabBarController: UITabBarControllerDelegate  {
      func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -&gt; Bool {
          guard let fromView = selectedViewController?.view,
                let toView = viewController.view else { return false }
          if fromView != toView {
              toView.transform = CGAffineTransform(translationX: -90, y: 0)
              UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: {
                  toView.transform = CGAffineTransform(translationX: 0, y: 0)
              })
          }; return true
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>class TabBarController: UITabBarController {
      override func viewDidLoad() {
          super.viewDidLoad()
          delegate = self
      }
  }
  </code></pre>
  
  <p><strong>How to fix this?</strong></p>
  
  <hr>
  
  <p><sup>[1]</sup>
  I would very much like to add a gif from the Facebook app. The problem is that I don't want to censor the video and just reveal too much of my data. (Even if fb already has them). Also on youtube I didn't find a suitable recording. Please try it yourself in the fb app in iOS.</p>