Last active
September 20, 2016 11:21
-
-
Save spotlessicode/3f7aedd9d37ea4d1cedcaea010c5b4cb to your computer and use it in GitHub Desktop.
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 characters
| override func perform() { | |
| //set the ViewControllers for the animation | |
| let sourceView = self.source.view as UIView! | |
| let destinationView = self.destination.view as UIView! | |
| let window = UIApplication.shared.delegate?.window! | |
| //set the destination View center | |
| destinationView?.center = CGPoint(x: (sourceView?.center.x)!, y: (sourceView?.center.y)! - (destinationView?.center.y)!) | |
| // the Views must be in the Window hierarchy, so insert as a subview the destionation above the source | |
| window?.insertSubview(destinationView!, aboveSubview: sourceView!) | |
| //create UIAnimation- change the views's position when present it | |
| UIView.animate(withDuration: 0.4, | |
| animations: { | |
| destinationView?.center = CGPoint(x: (sourceView?.center.x)!, y: (sourceView?.center.y)!) | |
| sourceView?.center = CGPoint(x: (sourceView?.center.x)!, y: 0 + 2 * (destinationView?.center.y)!) | |
| }, completion: { | |
| (value: Bool) in | |
| elf.source.navigationController?.pushViewController(self.destination, animated: false) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment