- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
Second *second = [[Second alloc] init];
second.title = @"second";
ViewController *aView = [[ViewController alloc] init];
aView.title = @"aView";
UITabBarController *tabBarController = [[UITabBarController alloc] init];
NSArray *tabBarArray = [NSArray arrayWithObjects:[[UINavigationController alloc] initWithRootViewController:second], [[UINavigationController alloc] initWithRootViewController:aView], nil];
tabBarController.viewControllers = tabBarArray;
tabBarController.selectedIndex = 0;
self.window.rootViewController = tabBarController;
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeFont : [UIFont systemFontOfSize:12],UITextAttributeTextColor : [UIColor redColor]} forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeFont : [UIFont systemFontOfSize:12],UITextAttributeTextColor : [UIColor blueColor]} forState:UIControlStateSelected];
for (UITabBarItem *tabBarItem in tabBarController.tabBar.items)
{
tabBarItem.image = [[UIImage imageNamed:@"31.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//设置显示图片原本的颜色
tabBarItem.selectedImage = [[UIImage imageNamed:@"31_select.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tabBarItem.title = @"11";
}
return YES;
}
代码附上