使用自定义类执行unwind-segue

时间:2015-09-28 13:47:40

标签: ios storyboard segue unwind-segue

我不想为此使用NavigationController。

我在两个ViewControllers之间有一个Segue(Show(Push)和一个自定义类UIStoryboardSegue)。现在我想“弹出”当前的ViewController,经过一些阅读后,我认为这被称为“unwind segue”。

  1. 我有一个在运行时添加代码的UIButton。如何将unwind segue添加到此按钮?

  2. 如何将自定义类用于展开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)
        }
    )
    }
    

0 个答案:

没有答案