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

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

    1. 如何更改选中和未选中的标签栏图像颜色

      时间:2023-06-13

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

        <tbody id='pu1pN'></tbody>
        • <tfoot id='pu1pN'></tfoot>

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

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

                <legend id='pu1pN'><style id='pu1pN'><dir id='pu1pN'><q id='pu1pN'></q></dir></style></legend>
                本文介绍了如何更改选中和未选中的标签栏图像颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试更改 iOS 应用程序中标签栏项目的颜色.

                I'm trying to change the color of a tab bar item in iOS app.

                子视图控制器嵌入在导航控制器中.

                The child view controllers are embedded in an navigation controller.

                我在 AppDelegate 中添加了这段代码,它只是改变了文本的颜色.

                I have added this code in AppDelegate which just changes the color of the text.

                 [UITabBarItem.appearance setTitleTextAttributes:
                 @{NSForegroundColorAttributeName : [UIColor colorWithRed:38/255.0 green:54/255.0 blue:73/255.0 alpha:1.0]}
                                                       forState:UIControlStateNormal];
                
                 [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : kColorTabbarNavigationBarTint}
                                                       forState:UIControlStateSelected];
                

                在图像资产内部,如果我将特定图像渲染为原始图像,它可以工作,但选择颜色不适用于图像.

                And inside the image assets,if I make the particular image to be rendered as original it works, but the selection color does not work for the image.

                请告诉我可以做什么.

                提前谢谢...

                推荐答案

                尝试以下代码:当你想以编程方式设置时.

                Try below code : When you want to set programatically.

                // get your TabBarController
                //UITabBarController *tabBarController = self.tabBarController
                UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 
                UITabBar *tabBar = tabBarController.tabBar;
                
                UITabBarItem *tabItem1 = [tabBar.items objectAtIndex:0];
                [tabItem1 setSelectedImage:[UIImage imageNamed:@"selectimg"]];
                tabItem1.selectedImage = [[UIImage imageNamed:@"selectimg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem1.image = [[UIImage imageNamed:@"deselectimg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem1.title = @"xxxx";
                
                UITabBarItem *tabItem2 = [tabBar.items objectAtIndex:1];
                tabItem2.selectedImage = [[UIImage imageNamed:@"selectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem2.image = [[UIImage imageNamed:@"deselectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem2.title = @"xxxx";
                
                UITabBarItem *tabItem3 = [tabBar.items objectAtIndex:2];
                tabItem3.selectedImage = [[UIImage imageNamed:@"selectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem3.image = [[UIImage imageNamed:@"deselectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem3.title = @"xxxx";
                
                UITabBarItem *tabItem4 = [tabBar.items objectAtIndex:3];
                tabItem4.selectedImage = [[UIImage imageNamed:@"selectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem4.image = [[UIImage imageNamed:@"deselectimg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
                tabItem4.title = @"xxxx";
                

                或者您可以在情节提要中设置它,选择特定的选项卡项目并见下文

                Or you can set it in storyboard, Select particular tab item and see below

                这篇关于如何更改选中和未选中的标签栏图像颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:以编程方式定义新的导航控制器顺序/堆栈? 下一篇:自定义 UITabBarController 和 UINavigationController

                相关文章

              1. <small id='kMSRH'></small><noframes id='kMSRH'>

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

                  <tfoot id='kMSRH'></tfoot>
                  <legend id='kMSRH'><style id='kMSRH'><dir id='kMSRH'><q id='kMSRH'></q></dir></style></legend>

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