1
私は自分のアプリケーションのカスタムトランジションを作成していますが、コピー先のビューのスナップショットを作成しようとすると、常に空の白い四角形として表示されます。私はこれがカスタムpush
移行であり、ビューのモーダルプレゼンテーションではないことに注意してください。モーダルを提示すると、スナップショットが機能しているように見えます。これはカスタムpush
/pop
遷移の通常の動作ですか?次のようにカスタムUIViewControllerトランジションのUIViewスナップショット
私が書いたコードは次のとおりです。それがレンダリングされる前に
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
guard let toViewController = transitionContext.viewController(forKey: .to) as? CultureViewController else {
return
}
let containerView = transitionContext.containerView
let finalFrame = transitionContext.finalFrame(for: toViewController)
let snapshot = toViewController.view.snapshotView(afterScreenUpdates: true)
snapshot?.frame = UIScreen.main.bounds
containerView.addSubview(snapshot!)
toViewController.view.transform = CGAffineTransform(translationX: 0, y: toViewController.view.bounds.height)
//containerView.addSubview(toViewController.view)
let duration = transitionDuration(using: transitionContext)
UIView.animateKeyframes(withDuration: duration, delay: 0, options: .calculationModeCubic, animations: {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1, animations: {
toViewController.view.frame = finalFrame
})
}, completion: { _ in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
})
}
このスニペットを含むクラス全体を投稿することができますか。 –
これを理解したことがありますか?まだこの正確な問題を見ている。 – Danny