在 Xcode 11 beta 中编译我的一个应用程序后,我注意到导航栏在prefersLargeTitles
设置时没有背景。这是预期的行为吗?
我注意到这是消息应用程序现在向下滚动时的工作方式,并且可以看到大标题,没有导航栏背景。
以下是用于设置navBar
属性的代码:
override func viewWillAppear(_ animated: Bool) {
let textAttributes = [NSAttributedString.Key.foregroundColor:ThemeManager.shared.default1]
self.navigationController?.navigationBar.largeTitleTextAttributes = textAttributes
self.navigationController?.navigationBar.titleTextAttributes = textAttributes
self.navigationController?.navigationBar.tintColor = ThemeManager.shared.default1
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationController?.navigationBar.prefersLargeTitles = true
let nav = self.navigationItem
nav.title = "My Profile"
}
以下是显示差异的几张图片:
左,在 Xcode 10 上编译,右,Xcode 11 beta:
在 11 Beta 版本上向上滚动后,背景会重新淡入。请注意,未在 Xcode 11 Beta 中编译的应用程序仍会以正常方式运行,只是在编译后由于某种原因发生变化。这是有意的,我将如何恢复原始行为?