0

我看到了这篇文章,我现在对 iOS14 也有同样的问题。我看到导航标题显示为小而不是大,直到我向下滚动集合视图。我想默认显示大标题,仅当用户向上滚动集合视图时才显示小标题。

我使用 .sizeToFit() 就像人们在帖子中所说的那样,但从来没有真正起作用。

在我的视图控制器中,我有一个集合视图和一个导航栏,下面的代码在 viewdidload 函数中被调用。

override func viewDidLoad() {
    setupNavigationBar()
}

func setupNavigationBar() {
    let appearance = UINavigationBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = .red
    appearance.shadowColor = .clear
    appearance.titleTextAttributes = [.foregroundColor: .blue, .font: UIFont.navBarSmallTitleBold()]
    appearance.largeTitleTextAttributes = [.foregroundColor: .blue), .font: UIFont.navBarLargeTitleBold()]
    
    navigationItem.standardAppearance = appearance
    navigationItem.scrollEdgeAppearance = appearance
    navigationItem.compactAppearance = appearance
    
    navigationItem.largeTitleDisplayMode = .always
    navigationController?.navigationBar.prefersLargeTitles = true
    navigationController?.navigationBar.sizeToFit()
    
    navigationItem.title = "TEST"
    navigationItem.rightBarButtonItem = editButtonItem
    extendedLayoutIncludesOpaqueBars = true

}

为了默认显示大标题,是否还有其他内容需要更新?

4

0 回答 0