2015-12-21 98 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,並從左到右過渡彈出視圖切換到根視圖。