UIStoryboardSegue sourceViewController上面的sourceViewController

时间:2015-09-21 11:04:25

标签: ios swift storyboard segue

我希望使用segue“滑出”destinationViewController上方的视图控制器。这是我的代码:

override func perform()
{
    let src = self.sourceViewController
    let dst = self.destinationViewController

    dst.view.superview?.insertSubview(src.view, aboveSubview: dst.view)
    src.view.transform = CGAffineTransformMakeTranslation(0, 0)

    UIView.animateWithDuration(0.25,
        delay: 0.0,
        options: UIViewAnimationOptions.CurveEaseInOut,
        animations: {
            src.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width * -1, 0)
        },
        completion: { finished in
            src.presentViewController(dst, animated: false, completion: nil)
        }
    )
}

幻灯片看起来不错,但是在动画期间,destinationViewController全黑,当动画完成时,destinationViewController显示正确。

如何在segue动画期间显示它?

编辑:

解决了它:

override func perform()
{
    let src = self.sourceViewController
    let dst = self.destinationViewController

    src.view.superview?.insertSubview(dst.view, belowSubview: src.view)
    dst.view.transform = CGAffineTransformMakeTranslation(0, 0)

    UIView.animateWithDuration(0.25,
        delay: 0.0,
        options: UIViewAnimationOptions.CurveEaseInOut,
        animations: {
            src.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width * -1, 0)
        },
        completion: { finished in
            src.presentViewController(dst, animated: false, completion: nil)
        }
    )
}

2 个答案:

答案 0 :(得分:2)

试试这个:

ggplot

答案 1 :(得分:0)

尝试将Storyboard ID添加到ViewController。