0
我有這個從左到右的代碼,但我希望它做到從右到左。我會如何去做這件事?我會如何在相反的方向使這個segue?
let screenWidth = (UIScreen.mainScreen().bounds).width
let screenHeight = (UIScreen.mainScreen().bounds).height
let firstVCView = sourceViewController.view
let secondVCView = destinationViewController.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.3, animations: {() -> Void in
firstVCView.frame = CGRectOffset(firstVCView.frame, -screenWidth, 0.0)
secondVCView.frame = CGRectOffset(secondVCView.frame, -screenWidth, 0.0)
}) { (Finished) -> Void in
self.sourceViewController.presentViewController(self.destinationViewController ,
animated: false,
completion: nil)
}
也許這可以幫助你http://stackoverflow.com/a/35574014/1622430 – carmine
@carmine Mmm。看起來,這樣做的方式是將視圖控制器放在前面,而不是在Snapchat中滑動的位置。 –