Segue 右左过渡
Posted
技术标签:
【中文标题】Segue 右左过渡【英文标题】:Segue Right Left transition 【发布时间】:2015-12-21 11:12:30 【问题描述】:我有一些代码这是描述从左到右转换的代码
class AGSegue: UIStoryboardSegue
override func perform()
let sourceViewController = self.sourceViewController
let destinationViewController = self.destinationViewController
// Creates a screenshot of the old viewcontroller
let duplicatedSourceView: UIView = sourceViewController.view.snapshotViewAfterScreenUpdates(false)
// the screenshot is added above the destinationViewController
destinationViewController.view.addSubview(duplicatedSourceView)
sourceViewController.presentViewController(destinationViewController, animated: false, completion:
// it is added above the destinationViewController
destinationViewController.view.addSubview(duplicatedSourceView)
UIView.animateWithDuration(0.5, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: () -> Void in
// slides the sourceViewController to the right
duplicatedSourceView.transform = CGAffineTransformMakeTranslation(sourceViewController.view.frame.size.width, 0)
) (finished: Bool) -> Void in
duplicatedSourceView.removeFromSuperview()
)
我只需要从右到左的过渡
【问题讨论】:
【参考方案1】:要提供过渡动画效果,请删除您所做的那些繁重的工作并选择UINavigationViewController
,它将允许推送和弹出动画以供查看,并为每个过渡保持较低的磁盘空间。如果您希望 UIViewController
从右到左转换,则将该视图推送到 UINavigationViewController
并将从左到右转换弹出视图到根视图。
【讨论】:
以上是关于Segue 右左过渡的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Modal Segue 的过渡中添加完整的卷曲效果?