使用 HERO 转换更改根视图控制器

Change root view controller using HERO transition

我有这个代码....

 UIView.transition(with: window!, duration: 0.3, options: **animation**, animations: {
            window!.rootViewController = rootVC
        }, completion: nil

是否可以将 Hero 过渡替换为“动画”变量?

举个例子:

   let current = window.rootViewController!
   let transition = HeroTransition()
   // Collapse vertically in dismissal, over 1 second.
   current.view.hero.modifiers = [.scale(x: 1, y: 0.1, z: 1), .duration(1), .fade]
   // Rotate in, over 2 seconds.
   replacement.view.hero.modifiers = [.rotate(z:1.6), .duration(2), .fade]

   transition.transition(from: current, to: replacement, in: window) { (finished) in
      window.rootViewController = replacement
                
   }