簡體   English   中英

導航欄在推送到新視圖時會縮小 controller

[英]Navigation bar shrinks when pushed to the new view controller

我有一個詳細視圖 controller,它有顯示用戶信息的tableView 但是,當我從另一個視圖 controller 推到詳細視圖 controller 時,導航欄總是會縮小,即使我強制成為大標題而不是在其他任何地方設置它。 如果我向下滾動,它會顯示為一個大標題。 你以前遇到過這樣的問題嗎?

 override func viewWillAppear(_ animated: Bool) {
     super.viewWillAppear(animated)

     navigationItem.largeTitleDisplayMode = .always
     navigationController?.navigationBar.prefersLargeTitles = true
 }

注:版本,iOS 14.2

您需要設置外觀。

 let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.configureWithOpaqueBackground()
    navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor(named: "menuNavBarTitle") ?? .red]
    navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor(named: "menuNavBarTitle") ?? .red]
    navBarAppearance.backgroundColor = .systemBackground
    navigationController?.navigationBar.standardAppearance = navBarAppearance
    navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
    self.navigationController?.navigationBar.prefersLargeTitles = true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM