<small id='6wgEM'></small><noframes id='6wgEM'>

      • <bdo id='6wgEM'></bdo><ul id='6wgEM'></ul>

        <i id='6wgEM'><tr id='6wgEM'><dt id='6wgEM'><q id='6wgEM'><span id='6wgEM'><b id='6wgEM'><form id='6wgEM'><ins id='6wgEM'></ins><ul id='6wgEM'></ul><sub id='6wgEM'></sub></form><legend id='6wgEM'></legend><bdo id='6wgEM'><pre id='6wgEM'><center id='6wgEM'></center></pre></bdo></b><th id='6wgEM'></th></span></q></dt></tr></i><div id='6wgEM'><tfoot id='6wgEM'></tfoot><dl id='6wgEM'><fieldset id='6wgEM'></fieldset></dl></div>
        <legend id='6wgEM'><style id='6wgEM'><dir id='6wgEM'><q id='6wgEM'></q></dir></style></legend>

      1. <tfoot id='6wgEM'></tfoot>
      2. iOS14 navigationItem.largeTitleDisplayMode = .always 不工作

        时间:2023-06-13

          1. <legend id='o1FfS'><style id='o1FfS'><dir id='o1FfS'><q id='o1FfS'></q></dir></style></legend>

              <bdo id='o1FfS'></bdo><ul id='o1FfS'></ul>
            • <tfoot id='o1FfS'></tfoot>
            • <small id='o1FfS'></small><noframes id='o1FfS'>

                  <tbody id='o1FfS'></tbody>
                <i id='o1FfS'><tr id='o1FfS'><dt id='o1FfS'><q id='o1FfS'><span id='o1FfS'><b id='o1FfS'><form id='o1FfS'><ins id='o1FfS'></ins><ul id='o1FfS'></ul><sub id='o1FfS'></sub></form><legend id='o1FfS'></legend><bdo id='o1FfS'><pre id='o1FfS'><center id='o1FfS'></center></pre></bdo></b><th id='o1FfS'></th></span></q></dt></tr></i><div id='o1FfS'><tfoot id='o1FfS'></tfoot><dl id='o1FfS'><fieldset id='o1FfS'></fieldset></dl></div>
                • 本文介绍了iOS14 navigationItem.largeTitleDisplayMode = .always 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个ViewController和一个DetailViewController,在ViewControllerViewDidLoad我设置如下代码,目的是让ViewController总是使用大标题

                  I have a ViewController and a DetailViewController, in the ViewDidLoad of the ViewController I set the following code, the purpose is to make the ViewController always use the large title

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

                  DetailViewControllerViewDidLoad中我设置如下代码,目的是让DetailViewController不使用大标题

                  In the ViewDidLoad of the DetailViewController I set the following code, the purpose is to make the DetailViewController not use the large title

                  navigationItem.largeTitleDisplayMode = .never
                  

                  当我从 DetailViewController 返回到 ViewController 时,ViewController 中显示的是小标题而不是大标题.此代码在 iOS12 和 iOS13 中是正确的.如何让ViewController在iOS14上一直显示大标题?

                  When I return from DetailViewController to ViewController, the small title is displayed instead of the large title in ViewController. This code is correct in iOS12 and iOS13. How to make the ViewController always display the large title on iOS14?

                  目前正在使用 App Store 中的 Xcode12

                  Currently using Xcode12 from the App Store

                  推荐答案

                  使用我的扩展:

                  extension UIViewController {
                  func configureNavigationBar(largeTitleColor: UIColor, backgoundColor: UIColor, tintColor: UIColor, title: String, preferredLargeTitle: Bool) {
                  if #available(iOS 13.0, *) {
                      let navBarAppearance = UINavigationBarAppearance()
                      navBarAppearance.configureWithOpaqueBackground()
                      navBarAppearance.largeTitleTextAttributes = [.foregroundColor: largeTitleColor]
                      navBarAppearance.titleTextAttributes = [.foregroundColor: largeTitleColor]
                      navBarAppearance.backgroundColor = backgoundColor
                  
                      navigationController?.navigationBar.standardAppearance = navBarAppearance
                      navigationController?.navigationBar.compactAppearance = navBarAppearance
                      navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
                  
                      navigationController?.navigationBar.prefersLargeTitles = preferredLargeTitle
                      navigationController?.navigationBar.isTranslucent = false
                      navigationController?.navigationBar.tintColor = tintColor
                      navigationItem.title = title
                  
                  } else {
                      // Fallback on earlier versions
                      navigationController?.navigationBar.barTintColor = backgoundColor
                      navigationController?.navigationBar.tintColor = tintColor
                      navigationController?.navigationBar.isTranslucent = false
                      navigationItem.title = title
                    }
                   }
                  }
                  

                  在 viewWillAppear 中设置导航栏:

                  set your navigation bar in viewWillAppear:

                  override func viewWillAppear(_ animated: Bool) {
                      super.viewWillAppear(animated)
                      configureNavigationBar(largeTitleColor: .white, backgoundColor: .yourColor, tintColor: .white, title: "YourTitle", preferredLargeTitle: true)
                  }
                  

                  现在调用显示你的细节控制器的函数:

                  now cal the function that present your detail controller:

                  @objc func DetailController(){
                      let controller = DetailViewController()
                      controller.navigationItem.largeTitleDisplayMode = .never
                      navigationController?.pushViewController(controller, animated: true)
                  }
                  

                  这是结果:

                  这篇关于iOS14 navigationItem.largeTitleDisplayMode = .always 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:没有 UITabBarController 的 UITabBar 功能 下一篇:在 UINavigationController 上创建返回箭头形状的 leftBarButtonItem

                  相关文章

                    <tfoot id='I2J2s'></tfoot>
                  1. <small id='I2J2s'></small><noframes id='I2J2s'>

                    • <bdo id='I2J2s'></bdo><ul id='I2J2s'></ul>

                    1. <legend id='I2J2s'><style id='I2J2s'><dir id='I2J2s'><q id='I2J2s'></q></dir></style></legend>

                    2. <i id='I2J2s'><tr id='I2J2s'><dt id='I2J2s'><q id='I2J2s'><span id='I2J2s'><b id='I2J2s'><form id='I2J2s'><ins id='I2J2s'></ins><ul id='I2J2s'></ul><sub id='I2J2s'></sub></form><legend id='I2J2s'></legend><bdo id='I2J2s'><pre id='I2J2s'><center id='I2J2s'></center></pre></bdo></b><th id='I2J2s'></th></span></q></dt></tr></i><div id='I2J2s'><tfoot id='I2J2s'></tfoot><dl id='I2J2s'><fieldset id='I2J2s'></fieldset></dl></div>