Swipe between tabs

How can I get a side-by-side transition using the tabBarController. Just like the "regular" ScrollView paging.

Something like that: enter image description here

I am currently using CrossDissolve:

class TransitioningObject: NSObject, UIViewControllerAnimatedTransitioning {

  func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
    let fromView: UIView = transitionContext.viewForKey(UITransitionContextFromViewKey)!
    let toView: UIView = transitionContext.viewForKey(UITransitionContextToViewKey)!

    transitionContext.containerView()!.addSubview(fromView)
    transitionContext.containerView()!.addSubview(toView)

    UIView.transitionFromView(fromView, toView: toView, duration: transitionDuration(transitionContext), options: UIViewAnimationOptions.TransitionCrossDissolve) { finished in
        transitionContext.completeTransition(true)
    }
  }

  func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
    return 0.25
  }
}

As an extension of the side transition, I would like to add a swipe gesture on the self.view tab. But this is a later problem, now I need to figure out how to make the transition.

+4
source share

Source: https://habr.com/ru/post/1622905/


All Articles