【问题标题】:Navigation bar shrinks when pushed to the new view controller导航栏在推送到新视图控制器时会缩小
【发布时间】:2020-12-28 11:30:34
【问题描述】:

我有一个详细视图控制器,它有 tableView 显示用户信息。但是当我从另一个视图控制器推送到详细视图控制器时,导航栏总是缩小,即使我强制成为大标题而不是在其他任何地方设置它。如果我向下滚动,它会显示为一个大标题。你以前遇到过这样的问题吗?

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

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

注意:版本,iOS 14.2

【问题讨论】:

    标签: ios swift iphone xcode ios14


    【解决方案1】:

    你需要设置外观。

     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
    

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 2014-01-11
      • 2018-09-24
      • 1970-01-01
      相关资源
      最近更新 更多