標籤:
1,firstVCView 為你當前view 2,secondVCView 為你需要跳轉到的view 3,viewCon 同第二項不要傳入view直接傳入對象即可。
*這裡是調用 UIViewObject 為你要跳轉的類 id是你需要傳遞的值
let view = UIViewObject()
view.id = self.id
self.performAnimationBack(self.view, secondVCView: lineList.view, viewCon: lineList)
// 自訂過場動畫 func performAnimationBack(firstVCView: UIView, secondVCView: UIView, viewCon: UIViewController) { // Assign the source and destination views to local variables. // Get the screen width and height. let screenWidth = UIScreen.mainScreen().bounds.size.width let screenHeight = UIScreen.mainScreen().bounds.size.height // Specify the initial position of the destination view. secondVCView.frame = CGRectMake(-screenWidth, 0.0, screenWidth, screenHeight) // Access the app‘s key window and insert the destination view above the current (source) one. let window = UIApplication.sharedApplication().keyWindow window?.insertSubview(secondVCView, aboveSubview: firstVCView) // Animate the transition. UIView.animateWithDuration(0.4, animations: { () -> Void in firstVCView.frame = CGRectOffset(firstVCView.frame, screenWidth, 0.0) secondVCView.frame = CGRectOffset(secondVCView.frame, screenWidth, 0.0) }) { (Finished) -> Void in// self.dismissViewControllerAnimated(true, completion: nil) self.presentViewController(viewCon, animated: false, completion: nil) } }
IOS 自訂轉場動畫