我在导航栏上使用大标题,当我点击一个单元格以转到下一个 Controller 时,大标题具有奇怪的动画(如下面的gif所示)。它不会立即消失。
我尝试了以下解决方案,但什么也没有(https://www.morningswiftui.com/blog/fix-large-title-animation-on-ios13)
我的代码:
在第一个View Controller上:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationItem.title = "New Order"
navigationController?.navigationBar.prefersLargeTitles = true
}
在Second View Controller(带有大标题)上:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationItem.title = "Menu"
self.navigationController?.navigationBar.prefersLargeTitles = false
}
编辑:
法比奥的答案是解决方案,但是现在我遇到了另一个问题:
当我点击一个单元格时,导航栏的一部分是黑色的(如下图所示)
最佳答案
第二个问题:
在SceneDelegate中:var window: UIWindow?
在功能场景中放入以下行:
window?.backgroundColor = .yourColor
像这样:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
window?.backgroundColor = .white
}
设置您想要的颜色,就是这样:)
关于ios - 导航栏大标题-动画问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59217253/