Skip to content

Instantly share code, notes, and snippets.

@ajonno
Created June 28, 2015 01:42
Show Gist options
  • Save ajonno/114321dda5d2ab36260a to your computer and use it in GitHub Desktop.
Save ajonno/114321dda5d2ab36260a to your computer and use it in GitHub Desktop.
Custom segue animation DONE RIGHT (no post render flashing)
class InitialLBPSegue: UIStoryboardSegue {
override func perform() {
var firstVCView = sourceViewController.view as UIView!
var thirdVCView = destinationViewController.view as UIView!
let window = UIApplication.sharedApplication().keyWindow
window?.insertSubview(thirdVCView, belowSubview: firstVCView)
thirdVCView.transform = CGAffineTransformScale(thirdVCView.transform, 0.001, 0.001)
UIView.animateWithDuration(0.5, animations: { () -> Void in
firstVCView.transform = CGAffineTransformScale(thirdVCView.transform, 0.001, 0.001)
}) { (Finished) -> Void in
UIView.animateWithDuration(0.5, animations: { () -> Void in
thirdVCView.transform = CGAffineTransformIdentity
}, completion: { (Finished) -> Void in
firstVCView.transform = CGAffineTransformIdentity
self.sourceViewController.presentViewController(self.destinationViewController as! UIViewController, animated: false, completion: nil)
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment