我在更改标签栏颜色时遇到了麻烦,因为我没有使用 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;
感谢你的帮助...