我正在尝试在导航栏中显示一个大的“标题”,但是要有清晰的背景。当向上滚动时,它将成为带有模糊效果的“导航栏”。
这看起来是正确的,但是在滚动时,动画似乎出现了问题。此外,过渡有时会卡住:
我的代码如下:
UINavigationController
:
override func viewDidLoad() {
super.viewDidLoad()
if #available(iOS 13.0, *) {
self.navigationBar.prefersLargeTitles = true
let style = UINavigationBarAppearance()
style.configureWithDefaultBackground()
style.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 18)]
self.navigationBar.standardAppearance = style
self.navigationBar.compactAppearance = style
//Configure Large Style
let largeStyle = UINavigationBarAppearance()
largeStyle.configureWithTransparentBackground()
largeStyle.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 28)]
self.navigationBar.scrollEdgeAppearance = largeStyle
}
}
UITableView
在UINavigationController
中。两者都是通过故事板的segue方式创建的。