如何使用滑动手势手动调整视图切换速度

时间:2016-03-03 11:27:33

标签: ios swift catransition

我正在使用CATransition为下一个视图从右边呈现另一个视图。现在我想使用滑动手势控制此视图转换,以便用户可以使用拇指速度和位置从左向右滑动以及屏幕上显示的下一个视图。这样用户就能感受到真实性

我的转换代码是

 let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let vc : drawer = storyboard.instantiateViewControllerWithIdentifier("drawerID") as! drawer



    let transition: CATransition = CATransition()
    let timeFunc : CAMediaTimingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
    transition.duration = 0.50
    transition.timingFunction = timeFunc
    transition.type = kCATransitionPush
    transition.subtype = kCATransitionFromRight    //kCATransitionFromLeft
    self.navigationController!.view.layer.addAnimation(transition, forKey: kCATransition)
    self.navigationController!.pushViewController(vc, animated: false)

0 个答案:

没有答案