2015-12-21 96 views
3

我有一些代码,这是描述从左至右Segue公司右左过渡

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() 
     } 
    }) 

} 

}

我只需要在正确的过渡到左

回答

0

为了给过渡代码过渡动画效果将删除您已完成的那些忙碌的工作,并为其提供UINavigationViewController,它将允许推送和弹出动画进行查看,并为每次转换保留较低的磁盘空间。如果您想从UIViewController的右到左过渡,则将该视图推入UINavigationViewController,并从左到右过渡弹出视图切换到根视图。