Fixes animation when launching a game when a game is already running
This commit is contained in:
parent
c16562c8ca
commit
df0c307be4
@ -12,8 +12,12 @@ class GamesPresentationController: UIPresentationController
|
||||
{
|
||||
private let blurView: UIVisualEffectView
|
||||
|
||||
override init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?)
|
||||
private let animator: UIViewPropertyAnimator
|
||||
|
||||
init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?, animator: UIViewPropertyAnimator)
|
||||
{
|
||||
self.animator = animator
|
||||
|
||||
self.blurView = UIVisualEffectView(effect: nil)
|
||||
self.blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
|
||||
@ -26,17 +30,17 @@ class GamesPresentationController: UIPresentationController
|
||||
|
||||
self.blurView.frame = CGRect(x: 0, y: 0, width: containerView.bounds.width, height: containerView.bounds.height)
|
||||
containerView.addSubview(self.blurView)
|
||||
|
||||
self.presentedViewController.transitionCoordinator?.animate(alongsideTransition: { (context) in
|
||||
|
||||
self.animator.addAnimations {
|
||||
self.blurView.effect = UIBlurEffect(style: .dark)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override func dismissalTransitionWillBegin()
|
||||
{
|
||||
self.presentedViewController.transitionCoordinator?.animate(alongsideTransition: { (context) in
|
||||
self.animator.addAnimations {
|
||||
self.blurView.effect = nil
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override func dismissalTransitionDidEnd(_ completed: Bool)
|
||||
|
||||
@ -48,7 +48,7 @@ extension GamesStoryboardSegue: UIViewControllerTransitioningDelegate
|
||||
|
||||
func presentationController(forPresented presentedViewController: UIViewController, presenting presentingViewController: UIViewController?, source: UIViewController) -> UIPresentationController?
|
||||
{
|
||||
let presentationController = GamesPresentationController(presentedViewController: presentedViewController, presenting: presentingViewController)
|
||||
let presentationController = GamesPresentationController(presentedViewController: presentedViewController, presenting: presentingViewController, animator: self.animator)
|
||||
return presentationController
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user