塞格动画黑屏/毛刺&延长滑动手势长度
问题描述:
我一直在关注如何实现自定义塞格的教程。使用滑动手势 - 我滑动手指的赛格作品,但不是一个平滑的过渡,其中第二个ViewController向上/向下滑动以取代当前的,我得到一个黑色屏幕,然后目标ViewController加载..塞格动画黑屏/毛刺&延长滑动手势长度
发生这种情况在前进和倒带时段。
我附加了我正常的赛格动画代码(不倒带)。
另外,当我轻轻滑动屏幕时,segue瞬间发生。我会如何做到这一点,所以直到我的手指被抬起(或在模拟器的情况下,鼠标点击),才会发生延续。我需要使用scrollViews吗?或者这种效果可能只是使用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)
}
}
}
}
答
试试这个代码,我改变了对self.destinationViewController...
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.storyboard.instantiateViewControllerWithIdentifier("YOUR_IDENTIFIER"),
animated: false,
completion: nil)
}
}
}
}
最后一行与您的视图控制器相匹配的故事板ID替换YOUR_IDENTIFIER
。
太棒了! - 非常感谢 - 我刚刚删除了最后一个动画块。你知道如何用swipeGestureRecognizer解决这个问题吗?一旦我做了最小的滑动,就会发生segue ..是否有可能没有segue开始,直到我开始或我需要使用scrollView才能获得所需的效果? – simlimsd3