我想为导航 Controller 实现自定义推送转换。
我首先实现了 UINavigationControllerDelegate
,我在其中返回了一个 UIViewControllerAnimatedTransitioning
的对象。
在这门课中,我想拍摄目标 View 的快照,以便为其设置动画。但是,对于推送序列,这不起作用 - 快照是空的。 [当我弹出时,我设置了 afterScreenUpdates = false
并且一切正常]
guard let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from),
let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else {
return
}
guard let snapshot = toVC.view.snapshotView(afterScreenUpdates: true) else {
return }
// Problem:
// snapshot is an empty view!
最佳答案
为 -snapshotViewAfterScreenUpdates: 提供 true 意味着它需要回到运行循环才能实际绘制图像。如果您提供 NO,它会立即尝试,但如果您的 View 不在屏幕上或尚未绘制到屏幕上,则快照将为空。
关于ios - 快照 View (屏幕更新后 : true) returns an empty view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47024439/