3

i have swipe gesture that switch between tab bars when I swipe in the screen right or left its change the tab bar im in it How would I make it so it looks like it is sliding to the right or left tab bar rather than just instantly changing the tab bar

class SwipeGesture: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let left = UISwipeGestureRecognizer(target: self, action: #selector(swipeLeft))
        left.direction = .left
        self.view.addGestureRecognizer(left)

        let right = UISwipeGestureRecognizer(target: self, action: #selector(swipeRight))
        right.direction = .right
        self.view.addGestureRecognizer(right)

    }

    @objc func swipeLeft() {
        let total = self.tabBarController!.viewControllers!.count - 1
        tabBarController!.selectedIndex = min(total, tabBarController!.selectedIndex + 1)

    }

    @objc func swipeRight() {
        tabBarController!.selectedIndex = max(0, tabBarController!.selectedIndex - 1)
    }


}
mazenqp
  • 345
  • 4
  • 19

1 Answers1

1

You can achieve this effect using this pod

If you want to build it from scratch, you need to subclass containerView. Then put the view controllers (childVCs) inside a scrollView (scrolls only in horizontal direction).

Joseph Francis
  • 1,111
  • 1
  • 15
  • 26
  • if i cant do that then i need to rebuild my app from scratch i don't want no pods sorry i need code i know how to use it but i need code – mazenqp Nov 04 '17 at 14:37