所以,我已经用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
}
我应该怎么做才能让我的意见在我们之间切换后不会出现在导航栏下?我不想使用容器视图,因为每个视图都是自定义的。所有这些都是以编程方式制作的。
答案 0 :(得分:0)
我找到了答案。我把模态过渡称为错误。模态在主视图中全屏显示。我刚刚展示新视图并从那里调用模态时嵌入了导航:
func todaysMealsAction() {
let yourFoodVC = YourFoodVC()
yourFoodVC.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
let navBarOnModal: UINavigationController = UINavigationController(rootViewController: yourFoodVC)
self.present(navBarOnModal, animated: false, completion: nil)
}