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

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

        <bdo id='XlzKy'></bdo><ul id='XlzKy'></ul>

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

        如何以编程方式为 UINavigationController 子类化 UINavigationBar?

        时间:2023-05-17

          • <bdo id='2y9TK'></bdo><ul id='2y9TK'></ul>
              <tfoot id='2y9TK'></tfoot>

                <tbody id='2y9TK'></tbody>
                <legend id='2y9TK'><style id='2y9TK'><dir id='2y9TK'><q id='2y9TK'></q></dir></style></legend>

                <small id='2y9TK'></small><noframes id='2y9TK'>

              1. <i id='2y9TK'><tr id='2y9TK'><dt id='2y9TK'><q id='2y9TK'><span id='2y9TK'><b id='2y9TK'><form id='2y9TK'><ins id='2y9TK'></ins><ul id='2y9TK'></ul><sub id='2y9TK'></sub></form><legend id='2y9TK'></legend><bdo id='2y9TK'><pre id='2y9TK'><center id='2y9TK'></center></pre></bdo></b><th id='2y9TK'></th></span></q></dt></tr></i><div id='2y9TK'><tfoot id='2y9TK'></tfoot><dl id='2y9TK'><fieldset id='2y9TK'></fieldset></dl></div>
                • 本文介绍了如何以编程方式为 UINavigationController 子类化 UINavigationBar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在 iOS4 的应用程序中使用自定义 drawRect 函数在 UINavigationBar 上绘图,它不使用图像,仅使用 CoreGraphics.

                  I'm using a custom drawRect function to draw on UINavigationBar across my application in iOS4, it doesn't use images, only CoreGraphics.

                  由于iOS5的UINavigationBar类中无法实现drawRect,Apple建议继承UINavigationBar.

                  Since you can't implement drawRect in UINavigationBar category in iOS5, Apple is suggesting to subclass UINavigationBar.

                  navigationBar 时,如何用我在 UINavigationController 中的子类替换 UINavigationBar (因此它将与 iOS4 和 iOS5 兼容)code> 属性是只读的?

                  How is it possible to replace the UINavigationBar with my subclass in UINavigationController (so it'll be compatible with iOS4 and iOS5) when the navigationBar property is read only?

                  @property(nonatomic, readonly) UINavigationBar *navigationBar
                  

                  我根本没有在我的应用程序中使用 XIB,因此无法将 UINavigationBar 添加到 NIB 并通过 InterfaceBuilder 更改类.

                  I'm not using XIBs in my application at all, so adding a UINavigationBar to a NIB and changing the class via InterfaceBuilder is not an option.

                  推荐答案

                  从 iOS6 开始,通过使用 UINavigationControllers 方法 initWithNavigationBarClass 可以非常简单地完成此任务,而无需打乱其他类:toolbarClass:

                  As of iOS6, this is now quite simple to accomplish without swizzling or messing with other classes by using UINavigationControllers method initWithNavigationBarClass:toolbarClass:

                  - (id)initWithNavigationBarClass:(Class)navigationBarClass 
                                      toolbarClass:(Class)toolbarClass;
                  

                  来自文档:

                  初始化并返回一个新创建的导航控制器使用您的自定义栏子类.

                  Initializes and returns a newly created navigation controller that uses your custom bar subclasses.

                  针对 iOS6 更新了答案.

                  这篇关于如何以编程方式为 UINavigationController 子类化 UINavigationBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:警告的含义“在演示过程中!" 下一篇:如何在 iOS 中使用导航栏隐藏/显示视图的标签栏?

                  相关文章

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

                    <small id='JVHF6'></small><noframes id='JVHF6'>

                    1. <tfoot id='JVHF6'></tfoot>
                    2. <legend id='JVHF6'><style id='JVHF6'><dir id='JVHF6'><q id='JVHF6'></q></dir></style></legend>

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