自定义底部栏过渡到 Swift 中的另一个视图?

Custom Bottom Bar transition to another view in Swift?

所以,我用 UIButton 制作了一个自定义底部栏。现在我正在尝试复制过渡中的淡入淡出,因此当您单击底部栏中的一个按钮时,将发送到另一个视图控制器并显示该视图。我设法做到了,但我的导航栏不是自定义的,每当我切换视图时,主视图都会在导航栏下方。

我正在使用此代码:

//MARK: Main view
func yourFoodGoalAction() -> Bool {
    print("transition: YourFoodGoal")

    let nextViewController = YourFoodGoal()
    let toView = nextViewController.view

    UIView.transition(from: view!, to: toView!, duration: 0.3, options: [.transitionCrossDissolve]) { (true) in
        print("disolve")
        UIView.animate(withDuration: 0.3, animations: {
            self.navigationItem.title = "Your Goal"
        })
    }

    return true
}

并返回视图(反之亦然):

func selectedBarButtonAction() -> Bool {
        print("transition: YourFoodGoal")

        let nextViewController = YourFoodVC()
        let toView = nextViewController.view

        UIView.transition(from: view!, to: toView!, duration: 0.3, options: [.transitionCrossDissolve]) { (true) in
            UIView.animate(withDuration: 0.3, animations: {
                self.navigationItem.title = "Today's Meals"
            })
        }

        return true
    }

我应该怎么做才能让我的视图在它们之间切换后不会进入导航栏下方?我不想使用容器视图,因为每个视图都是自定义的。一切都是以编程方式制作的。

我找到了答案。我称模态转换错误。模式与主视图一起全屏显示。当我展示新视图并从那里调用模态时,我只是嵌入了导航:

func todaysMealsAction() {
    let yourFoodVC = YourFoodVC()
    yourFoodVC.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
    let navBarOnModal: UINavigationController = UINavigationController(rootViewController: yourFoodVC)
    self.present(navBarOnModal, animated: false, completion: nil)
}