• <small id='Vpgcr'></small><noframes id='Vpgcr'>

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

      <tfoot id='Vpgcr'></tfoot>

      1. UINavigationBar 在推送时更改颜色

        UINavigationBar change colors on push(UINavigationBar 在推送时更改颜色)

          <i id='7YhAO'><tr id='7YhAO'><dt id='7YhAO'><q id='7YhAO'><span id='7YhAO'><b id='7YhAO'><form id='7YhAO'><ins id='7YhAO'></ins><ul id='7YhAO'></ul><sub id='7YhAO'></sub></form><legend id='7YhAO'></legend><bdo id='7YhAO'><pre id='7YhAO'><center id='7YhAO'></center></pre></bdo></b><th id='7YhAO'></th></span></q></dt></tr></i><div id='7YhAO'><tfoot id='7YhAO'></tfoot><dl id='7YhAO'><fieldset id='7YhAO'></fieldset></dl></div>
        1. <small id='7YhAO'></small><noframes id='7YhAO'>

        2. <tfoot id='7YhAO'></tfoot>

            <legend id='7YhAO'><style id='7YhAO'><dir id='7YhAO'><q id='7YhAO'></q></dir></style></legend>
              • <bdo id='7YhAO'></bdo><ul id='7YhAO'></ul>
                  <tbody id='7YhAO'></tbody>

                • 本文介绍了UINavigationBar 在推送时更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在不同视图中的 UINavigationBar 处使用了 2 种不同的条形颜色.我在两个视图中都使用该方法更改颜色:

                  I'm using 2 different bar tint colors at UINavigationBar in different views. I'n changing color with that method in both views:

                  override func viewWillAppear(animated: Bool) {
                      super.viewWillAppear(animated)
                      self.navigationController?.navigationBar.barTintColor = COLOR
                  }
                  

                  当我点击后退按钮颜色变化不顺畅(你可以看到最后一秒闪烁).

                  When I tap on back button color is not changed smoothly (you can see blink on last second).

                  但如果只是向后滑动视图而不是点击返回按钮,一切都会好起来的.

                  But everything is okay if just swipe view back instead of tapping on back button.

                  如何在这两种情况下顺利过渡?

                  How to make smooth transition in both situations?

                  推荐答案

                  我编写了看起来使用起来最舒服的最终解决方案(不需要在自己的视图控制器中使用大量覆盖).它在 iOS 10 上完美运行,并且可以轻松用于自己的目的.

                  I've coded final solution that looks most comfortable to use (don't need to use a lot of overrides in own view controllers). It works perfectly at iOS 10 and easy adoptable for own purposes.

                  您可以查看 GitHub Gist 以获取完整的课程代码等详细的指南,我不会在这里发布完整的代码,因为 Stackoverflow 不是用来存储大量代码的.

                  You can check GitHub Gist for full class code and more detailed guide, I won't post full code here because Stackoverflow is not intended for storing a lot of code.

                  为 GitHub 下载 Swift 文件.要使其工作,只需使用 ColorableNavigationController 而不是 UINavigationController 并将所需的子视图控制器采用 NavigationBarColorable 协议.

                  Download Swift file for GitHub. To make it work just use ColorableNavigationController instead of UINavigationController and adopt needed child view controllers to NavigationBarColorable protocol.

                  示例:

                  class ViewControllerA: UIViewController, NavigationBarColorable {
                      public var navigationBarTintColor: UIColor? { return UIColor.blue }
                  
                      override func viewDidLoad() {
                          super.viewDidLoad()
                  
                          navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Push", style: .plain, target: self, action: #selector(self.showController))
                      }
                  
                      func showController() {
                          navigationController?.pushViewController(ViewControllerB(), animated: true)
                      }
                  }
                  
                  class ViewControllerB: UIViewController, NavigationBarColorable {
                      public var navigationBarTintColor: UIColor? { return UIColor.red }
                  }
                  
                  let navigationController = ColorableNavigationController(rootViewController: ViewControllerA())
                  

                  这篇关于UINavigationBar 在推送时更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to add a navigation controller programmatically in code but not as initial view controller(如何在代码中以编程方式添加导航控制器,但不作为初始视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                  View being blocked by UITransitionView after being presented(呈现后被 UITransitionView 阻止的视图)
                  <i id='45vu4'><tr id='45vu4'><dt id='45vu4'><q id='45vu4'><span id='45vu4'><b id='45vu4'><form id='45vu4'><ins id='45vu4'></ins><ul id='45vu4'></ul><sub id='45vu4'></sub></form><legend id='45vu4'></legend><bdo id='45vu4'><pre id='45vu4'><center id='45vu4'></center></pre></bdo></b><th id='45vu4'></th></span></q></dt></tr></i><div id='45vu4'><tfoot id='45vu4'></tfoot><dl id='45vu4'><fieldset id='45vu4'></fieldset></dl></div>
                    <tbody id='45vu4'></tbody>
                  <tfoot id='45vu4'></tfoot>

                    <small id='45vu4'></small><noframes id='45vu4'>

                        <bdo id='45vu4'></bdo><ul id='45vu4'></ul>
                        • <legend id='45vu4'><style id='45vu4'><dir id='45vu4'><q id='45vu4'></q></dir></style></legend>