Skip to content

Instantly share code, notes, and snippets.

@thomsmed
Last active December 20, 2021 15:44
Show Gist options
  • Select an option

  • Save thomsmed/f0a001f845170eb9bd17ec625e0ea445 to your computer and use it in GitHub Desktop.

Select an option

Save thomsmed/f0a001f845170eb9bd17ec625e0ea445 to your computer and use it in GitHub Desktop.
FullScreenTransitionManager.swift - From "Transition images to full screen animated" @ medium.com
//
// 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