我使用以下代码执行自定义segue:
class PopFromMiddleSegue: UIStoryboardSegue {
override func perform()
{
let sourceVC = self.sourceViewController
let destinationVC = self.destinationViewController
sourceVC.view.addSubview(destinationVC.view)
destinationVC.view.transform = CGAffineTransformMakeScale(0.05, 0.05)
UIView.animateWithDuration(0.5, delay: 0.0, options: .CurveEaseInOut, animations: { () -> Void in
destinationVC.view.transform = CGAffineTransformMakeScale(1.0, 1.0)
}) { (finished) -> Void in
destinationVC.view.removeFromSuperview()
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(0.001 * Double(NSEC_PER_SEC)))
dispatch_after(time, dispatch_get_main_queue()) {
sourceVC.presentViewController(destinationVC, animated: false, completion: nil)
}
}
}
}
在动画结束时destinationVC
闪烁一秒钟。您可以很快看到sourceVC
,然后动画完成。
如果我放//destinationVC.view.removeFromSuperview()
但是当我下次回到segue的那个视图时,我的应用程序崩溃了。
如何删除闪烁?非常感谢任何帮助。