Open Andriyas123 opened 7 years ago
Its a swift 3 issue, I am too, also hopeful for a solution to the issue.
Maybe move the let containerView = trainsitionContext.containerView
line above the guard statement.
And for the PresentMenuAnimator
, move the snapshot
into the guard statement.
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
guard
let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to),
let snapshot = fromVC.view.snapshotView(afterScreenUpdates: false)
else {
return
}
containerView.insertSubview(toVC.view, belowSubview: fromVC.view)
// replace main view with snapshot
snapshot.tag = MenuHelper.snapshotNumber
snapshot.isUserInteractionEnabled = false
snapshot.layer.shadowOpacity = 0.7
containerView.insertSubview(snapshot, aboveSubview: toVC.view)
fromVC.view.isHidden = true
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
animations: {
snapshot.center.x += UIScreen.main.bounds.width * MenuHelper.menuWidth
},
completion: { _ in
fromVC.view.isHidden = false
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
}
)
}
what is MenuHelper?
MenuHelper is just some file that tries to abstract the transition animation code.
Hello! I am trying to simply run this project but getting an error "Initializer for conditional binding must have optional type, not 'UIView'" in DismissAnimator.swift on the line of "let containerView = transitionContext.containerView":
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { guard let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from), let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to), let containerView = transitionContext.containerView else { return }
How do I fix that? Thanks!