Last active
December 20, 2021 15:44
-
-
Save thomsmed/f0a001f845170eb9bd17ec625e0ea445 to your computer and use it in GitHub Desktop.
FullScreenTransitionManager.swift - From "Transition images to full screen animated" @ medium.com
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
| // | |
| // FullScreenTransitionManager.swift | |
| // | |
| import Foundation | |
| import UIKit | |
| final class FullScreenTransitionManager: NSObject, UIViewControllerTransitioningDelegate { | |
| private let anchorViewTag: Int | |
| private weak var anchorView: UIView? | |
| init(anchorViewTag: Int) { | |
| self.anchorViewTag = anchorViewTag | |
| } | |
| func presentationController(forPresented presented: UIViewController, | |
| presenting: UIViewController?, | |
| source: UIViewController) -> UIPresentationController? { | |
| anchorView = (presenting ?? source).view.viewWithTag(anchorViewTag) | |
| return FullScreenPresentationController(presentedViewController: presented, presenting: presenting) | |
| } | |
| func animationController(forPresented presented: UIViewController, | |
| presenting: UIViewController, | |
| source: UIViewController) -> UIViewControllerAnimatedTransitioning? { | |
| FullScreenAnimationController(animationType: .present, anchorView: anchorView) | |
| } | |
| func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { | |
| FullScreenAnimationController(animationType: .dismiss, anchorView: anchorView) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment