Created
May 29, 2019 17:55
-
-
Save WildStudio/9d77bf694e1aa04893e2e0458868c87c to your computer and use it in GitHub Desktop.
Presentation transition animation
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
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
guard let toViewController = transitionContext | |
.viewController(forKey: .to) as? DetailViewController else { return } | |
let container = transitionContext.containerView | |
container.addSubview(toViewController.view) | |
toViewController.positionContainer(left: 20.0, | |
right: 20.0, | |
top: selectedCardFrame.origin.y + 20.0, | |
bottom: 0.0) | |
toViewController.view.backgroundColor = .clear | |
toViewController.setRoundedCorners(isRounded: false) | |
let duration = transitionDuration(using: transitionContext) | |
UIView.animate(withDuration: duration, animations: { | |
toViewController.positionContainer(left: 20.0, | |
right: 20.0, | |
top: 20.0, | |
bottom: 0.0) | |
toViewController.view.backgroundColor = Constant.backgroundColor | |
toViewController.setRoundedCorners(isRounded: true) | |
}) { (_) in | |
transitionContext.completeTransition(!transitionContext.transitionWasCancelled) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment