2017-11-03 128 views
2

我有滑动手势,当我在屏幕右侧或左侧滑动时,在标签栏之间切换其标签栏即时贴 我如何制作它,使其看起来像是向右滑动或左侧标签栏,而不是仅仅瞬间改变标签栏制作滑动手势动画

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) 
    } 


} 

回答

1

你可以,如果你想从头开始构建它使用该pod

达到这种效果,你需要继承containerView。然后将视图控制器(childVCs)放入scrollView(仅在水平方向滚动)。

+0

现在你告诉我,我无法做到这一点在刷卡的姿势,虽然它的工作?!.. – mazenqp

+0

如果我不能这样做,那么我需要从头开始重建我的应用程序我不想要没有豆荚抱歉,我需要代码我知道如何使用它,但我需要代码 – mazenqp