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

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

      <legend id='ikmhx'><style id='ikmhx'><dir id='ikmhx'><q id='ikmhx'></q></dir></style></legend>

    2. <small id='ikmhx'></small><noframes id='ikmhx'>

    3. 如何使用自定义 UINavigationBar

      时间:2023-05-30
        <tbody id='7OoLs'></tbody>

        <legend id='7OoLs'><style id='7OoLs'><dir id='7OoLs'><q id='7OoLs'></q></dir></style></legend>

        <small id='7OoLs'></small><noframes id='7OoLs'>

          • <bdo id='7OoLs'></bdo><ul id='7OoLs'></ul>

              <tfoot id='7OoLs'></tfoot>

              • <i id='7OoLs'><tr id='7OoLs'><dt id='7OoLs'><q id='7OoLs'><span id='7OoLs'><b id='7OoLs'><form id='7OoLs'><ins id='7OoLs'></ins><ul id='7OoLs'></ul><sub id='7OoLs'></sub></form><legend id='7OoLs'></legend><bdo id='7OoLs'><pre id='7OoLs'><center id='7OoLs'></center></pre></bdo></b><th id='7OoLs'></th></span></q></dt></tr></i><div id='7OoLs'><tfoot id='7OoLs'></tfoot><dl id='7OoLs'><fieldset id='7OoLs'></fieldset></dl></div>
                本文介绍了如何使用自定义 UINavigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有 UINavigationBar 的子类.

                @interface MyNavigationBar : UINavigationBar
                

                做了一些更改,现在希望我的应用程序 NavigationController 使用它:

                Made some changes and now want that my application NavigationController would use it:

                 _navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
                 [_window addSubview:[_navigationController view]];
                [self.window makeKeyAndVisible];
                

                我希望 _navigationControllerMyNavigationBar

                如何做到这一点?

                谢谢.

                推荐答案

                你必须创建一个带有 UINavaigationController 的 xib.然后,您可以在 Interface Builder 中选择 navigationBar 并将类更改为 UINavigationBar 的子类.

                You have to create a xib with a UINavaigationController in it. You can then select the navigationBar in Interface Builder and change the class to your subclass of UINavigationBar.

                然后为了更容易实例化,我向 `UINavigationController 添加了一个类别,例如:

                Then to make this a little easier to instantiate I add a category to `UINavigationController like:

                @interface UINavigationController (DSCNavigationController)
                
                + (UINavigationController *)dsc_navigationControllerWithRootViewController:(UIViewController *)rootViewController;
                
                @end
                
                @implementation UINavigationController (DSCNavigationController)
                
                + (UINavigationController *)dsc_navigationControllerWithRootViewController:(UIViewController *)rootViewController;
                {
                    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"DSCNavigationController" owner:nil options:nil];
                
                    NSAssert(1 == [topLevelObjects count], @"DSCNavigationController should have one top level object");
                
                    UINavigationController *navigationController = [topLevelObjects objectAtIndex:0];
                
                    NSAssert([navigationController isKindOfClass:[UINavigationController class]], @"Should have a UINavigationController");
                
                    [navigationController pushViewController:rootViewController animated:NO];
                
                    return navigationController;
                }
                
                @end
                

                在使用它的类的顶部,确保在我的情况下导入类别,它看起来像

                At the top of the class that uses it makes sure to import the category in my case it looks like

                #import "UINavigationController+DSCNavigationController"
                

                然后使用它看起来像

                MyViewController *myViewController = [[MyViewController  alloc] init];
                UINavigationController *navigationController = [UINavigationController dsc_navigationControllerWithRootViewController:myViewController];
                

                这篇关于如何使用自定义 UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 HTML5 在 UIWebView 中播放嵌入的视频 下一篇:用弧覆盖设置器

                相关文章

                最新文章

                1. <tfoot id='YHgCb'></tfoot>

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