【发布时间】:2015-07-13 08:51:49
【问题描述】:
我一直在关注如何实现自定义 segues 的教程。使用滑动手势 - 我滑动手指,segue 工作,但不是平滑过渡,第二个 ViewController 向上/向下滑动以替换当前的,我得到一个黑屏,然后目标 ViewController 加载..
这发生在前进和后退转场上。
我已经附上了我正常转场的动画代码(不是倒带)。
此外,当我轻轻滑动屏幕时,segue 会立即发生。我将如何做到这一点,直到我的手指被抬起(或者在模拟器的情况下,鼠标点击)之前不会发生segue。我必须使用滚动视图吗?或者仅使用 swipeGestureRecognizers 和自定义 segues 是否可能产生这种效果。
谢谢!
class FirstCustomSegue: UIStoryboardSegue {
override func perform() {
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
// Animate the transition.
UIView.animateWithDuration(0.4, animations: { () -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, 0.0, -screenHeight)
secondVCView.frame = CGRectOffset(secondVCView.frame, 0.0, -screenHeight)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController,
animated: false,
completion: nil)
}
}
}
}
【问题讨论】: