创建选项卡组
ViewController1 *viewCtrl1 = [[ViewController1 alloc] init];
ViewController2 *viewCtrl2 = [[ViewController2 alloc] init];
ViewController3 *viewCtrl3 = [[ViewController3 alloc] init];
ViewController4 *viewCtrl4 = [[ViewController4 alloc] init];
ViewController5 *viewCtrl5 = [[ViewController5 alloc] init];
UITabBarController *tabBarCtrl = [[UITabBarController alloc] init];
tabBarCtrl.viewControllers = @[viewCtrl1, viewCtrl2, viewCtrl3, viewCtrl4, viewCtrl5];
[self.window setRootViewController:tabBarCtrl];
[self.window setBackgroundColor:[UIColor whiteColor]];
[self.window makeKeyAndVisible];
设置选项卡样式
UIViewController *viewCtrl = tabBarCtrl.viewControllers[0];
UIImage *normalImage = [[UIImage imageNamed:@"shouye-normal"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *selectedImage = [[UIImage imageNamed:@"shouye-selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"首页" image:normalImage selectedImage:selectedImage];
item.badgeValue = @"99+";
viewCtrl.tabBarItem = item;
----------
tabBarCtrl.selectedIndex = 1;
----------
UITabBar *tabBar = tabBarCtrl.tabBar;
tabBar.barStyle = UIBarStyleBlack;
tabBar.barStyle = UIBarStyleDefault;
tabBar.tintColor = [UIColor redColor];
tabBar.barTintColor = [UIColor orangeColor];
tabBar.translucent = NO;
tabBar.backgroundImage = [UIImage imageNamed:@""];
tabBar.hidden = YES;