Ios 在没有xib文件的情况下更改选项卡栏颜色

Ios 在没有xib文件的情况下更改选项卡栏颜色,ios,objective-c,uitabbarcontroller,Ios,Objective C,Uitabbarcontroller,我在更改选项卡栏颜色时遇到了麻烦,因为我没有使用xib文件,而且我的代码结构对我没有任何帮助,请告诉我是否需要从头开始重写整个内容,如果不需要的话,我将非常感激^_^ 这是我的单个视图应用程序的appDelegate文件,我在这里创建了选项卡栏,其中包含与每个选项卡关联的导航栏,然后显示它们 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window makeKeyAndV

我在更改选项卡栏颜色时遇到了麻烦,因为我没有使用xib文件,而且我的代码结构对我没有任何帮助,请告诉我是否需要从头开始重写整个内容,如果不需要的话,我将非常感激^_^

这是我的单个视图应用程序的appDelegate文件,我在这里创建了选项卡栏,其中包含与每个选项卡关联的导航栏,然后显示它们

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];

self.firstTab = [[FirstTab alloc] initWithNibName:nil bundle:NULL];
self.firstNavigationController = [[UINavigationController alloc] initWithRootViewController:self.firstTab];
self.thirdTab = [[ThirdTab alloc] initWithNibName:nil bundle:NULL];
self.thirdNavigationController = [[UINavigationController alloc] initWithRootViewController:self.thirdTab];
self.tab2 = [[newsecViewController alloc] initWithNibName:@"newsecViewController" bundle:NULL];
self.tab2NavigationController = [[UINavigationController alloc] initWithRootViewController:self.tab2];
self.tab2.view.backgroundColor = [UIColor purpleColor];



//NSArray *tabs = [[NSArray alloc] initWithObjects:self.firstTab, self.secondTab, self.thirdTab, nil];
NSArray *tabBars = [[NSArray alloc] initWithObjects:self.firstNavigationController, self.tab2NavigationController, self.thirdNavigationController, nil];
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController setViewControllers:tabBars];
[self.window addSubview:self.tabBarController.view];
这是我的一个选项卡的代码示例

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self != nil) {
    self.title = @"Second";
    self.tabBarItem.image = [UIImage imageNamed:@"triangle.png"];

}
return self;

谢谢大家的帮助…

使用tabbar的tintColor属性。它在iOS 5.0及更高版本中可用

[tabBarController.tabBar setTintColor:[UIColor purpleColor]];

从iOS 7开始,当设置
UINavigationBar
UITabBar
的颜色时,使用
barTintColor
属性

[self.tabBarController.tabBar setBarTintColor:[UIColor purpleColor]];

在iOS 7下,
tintColor
设置所选选项卡的图像颜色。使用iOS 7下的
barTintColor
为实际选项卡着色。您希望更改哪种颜色?所有选项卡的整体颜色或所选选项卡图像的色调?iOS的哪个版本?