Created
March 19, 2015 20:02
-
-
Save marcboeren/165ed7de30178acfdad4 to your computer and use it in GitHub Desktop.
Revisions
-
marcboeren revised this gist
Mar 19, 2015 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes. -
marcboeren created this gist
Mar 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ @IBAction func segueToMe(segue: UIStoryboardSegue) { // segue back } override func segueForUnwindingToViewController(toViewController: UIViewController, fromViewController: UIViewController, identifier: String?) -> UIStoryboardSegue { if let id = identifier { if id == "returnToMainViewController" { let unwindSegue = UIStoryboardUnwindSegueFromRight(identifier: id, source: fromViewController, destination: toViewController) return unwindSegue } } return super.segueForUnwindingToViewController(toViewController, fromViewController: fromViewController, identifier: identifier) }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ import UIKit class UIStoryboardSegueFromRight: UIStoryboardSegue { override func perform() { let src = self.sourceViewController as UIViewController let dst = self.destinationViewController as UIViewController src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) dst.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width, 0) UIView.animateWithDuration(0.25, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { dst.view.transform = CGAffineTransformMakeTranslation(0, 0) }, completion: { finished in src.presentViewController(dst, animated: false, completion: nil) } ) } } class UIStoryboardUnwindSegueFromRight: UIStoryboardSegue { override func perform() { let src = self.sourceViewController as UIViewController let dst = self.destinationViewController as UIViewController src.view.superview?.insertSubview(dst.view, belowSubview: src.view) src.view.transform = CGAffineTransformMakeTranslation(0, 0) UIView.animateWithDuration(0.25, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: { src.view.transform = CGAffineTransformMakeTranslation(src.view.frame.size.width, 0) }, completion: { finished in src.dismissViewControllerAnimated(false, completion: nil) } ) } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Assign the class UIStoryboardSegueFromRight to the custom segue in the storyboard. To create an Unwind Segue, you'll need the code below in the first controller. You'll use the segueToMe to connect to the Exit in the second controller. Give that Unwind segue the identifier e.g. "returnToMainViewController".