Created
October 18, 2016 19:36
-
-
Save ekoranek12/280a45a5ac121b00c2faedc59056ad7f to your computer and use it in GitHub Desktop.
Custom Segue using Core Graphics transforms
This file contains 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
// | |
// AddPartySegue.swift | |
// Our | |
// | |
// Created by Eddie Koranek on 10/16/16. | |
// Copyright © 2016 Eddie Koranek. All rights reserved. | |
// | |
import UIKit | |
class AddPartySegue: UIStoryboardSegue { | |
override func perform() { | |
guard let sourceVC = source as? ViewController else { return } | |
guard let destinationVC = destination as? AddPartyViewController else { return } | |
UIApplication.shared.keyWindow?.addSubview(destinationVC.view) | |
destinationVC.dimmerView.alpha = 0.0 | |
destinationVC.blurView.alpha = 0.0 | |
destinationVC.hisToggle.transform = CGAffineTransform(translationX: -600, y: 0) | |
destinationVC.ourToggle.transform = CGAffineTransform(translationX: -400, y: 0) | |
destinationVC.herToggle.transform = CGAffineTransform(translationX: -200, y: 0) | |
destinationVC.cancelButton.transform = CGAffineTransform(translationX: 500, y: 0) | |
destinationVC.doneButton.transform = CGAffineTransform(translationX: 300, y: 0) | |
destinationVC.mainContentCard.transform = CGAffineTransform(translationX: 0, y: 800) | |
UIView.animate(withDuration: 0.4, animations: { | |
destinationVC.dimmerView.alpha = 0.25 | |
destinationVC.blurView.alpha = 1.0 | |
}, completion: nil) | |
UIView.animate(withDuration: 0.4, delay: 0.0, usingSpringWithDamping: 0.75, initialSpringVelocity: 0.8, options: UIViewAnimationOptions.allowUserInteraction, animations: { | |
destinationVC.mainContentCard.transform = CGAffineTransform.identity | |
}, completion: nil) | |
UIView.animate(withDuration: 0.8, delay: 0.0, usingSpringWithDamping: 0.70, initialSpringVelocity: 1.0, options: UIViewAnimationOptions.allowUserInteraction, animations: { | |
destinationVC.hisToggle.transform = CGAffineTransform.identity | |
destinationVC.ourToggle.transform = CGAffineTransform.identity | |
destinationVC.herToggle.transform = CGAffineTransform.identity | |
destinationVC.cancelButton.transform = CGAffineTransform.identity | |
destinationVC.doneButton.transform = CGAffineTransform.identity | |
}, completion: nil) | |
defer { | |
sourceVC.present(destination, animated: false, completion: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment