-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-
{
-
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
-
self.window.backgroundColor = [UIColor whiteColor];
-
-
#pragma mark - 设置tabBarItem
-
#pragma mark 第一个视图ViewController
-
-
HMT_AViewController * tabBarViewA = [[HMT_AViewController alloc] init];
-
-
tabBarViewA.tabBarItem.title = @"微信";
-
-
-
-
tabBarViewA.tabBarItem.badgeValue = @"3";
-
-
-
-
-
-
#pragma mark 第二个视图ViewController
-
-
HMT_BViewController * tabBarViewB = [[HMT_BViewController alloc] init];
-
-
-
tabBarViewB.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1];
-
-
tabBarViewB.tabBarItem.badgeValue = @"GO";
-
-
#pragma mark 第三个视图ViewController
-
HMT_CViewController * tabBarViewC = [[HMT_CViewController alloc] init];
-
tabBarViewC.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:2];
-
-
tabBarViewC.tabBarItem.badgeValue = @"new";
-
-
#pragma mark 第四个视图ViewController
-
HMT_DViewController * tabBarViewD = [[HMT_DViewController alloc] init];
-
tabBarViewD.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3];
-
-
tabBarViewD.tabBarItem.badgeValue = @"99";
-
-
#pragma mark 第五个视图ViewController
-
HMT_EViewController * tabBarViewE = [[HMT_EViewController alloc] init];
-
tabBarViewE.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:4];
-
-
tabBarViewE.tabBarItem.badgeValue = @"sky";
-
-
#pragma mark 第六个视图ViewController(系统默认能显示的最大视图个数是5个)
-
-
-
-
HMT_FViewController * tabBarViewF = [[HMT_FViewController alloc] init];
-
tabBarViewF.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:5];
-
-
tabBarViewF.tabBarItem.badgeValue = @"AG";
-
-
-
-
#pragma mark - 设置TabBarController
-
-
-
UITabBarController * tabBarController = [[UITabBarController alloc]init];
-
-
-
-
-
tabBarController.viewControllers = [NSArray arrayWithObjects:tabBarViewA,tabBarViewB,tabBarViewC,tabBarViewD,tabBarViewE,tabBarViewF, nil nil];
-
-
tabBarController.tabBar.tintColor = [UIColor greenColor];
-
-
tabBarController.tabBar.selectedImageTintColor = [UIColor brownColor];
-
-
-
-
tabBarController.selectedIndex = 3;
-
-
-
self.window.rootViewController = tabBarController;
-
-
[self.window makeKeyAndVisible];
-
return YES;
-
}
@最后效果如下图:
UITabBarController详解(介绍和设置),布布扣,bubuko.com
UITabBarController详解(介绍和设置)
原文:http://blog.csdn.net/zuoyou1314/article/details/38112103