RootViewController *rootVC=[[RootViewController alloc] init] SignInViewController *signVC = [[SignInViewController alloc]init]; //如果在这里指定tabitem标题,则在FirstViewController中指定self.tabBarItem.title则不生效 signVC.title = @"打卡"; UITabBarItem *signItem = [[UITabBarItem alloc]initWithTitle:@"打卡" image:nil tag:1]; [signItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]]; signVC.tabBarItem = signItem; TextViewController *textVC = [[TextViewController alloc]init]; signVC.title = @"备注"; UITabBarItem *textItem = [[UITabBarItem alloc]initWithTitle:@"备注" image:nil tag:2]; [textItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]]; textVC.tabBarItem = textItem; VisitViewController *visitVC = [[VisitViewController alloc]init]; visitVC.title = @"拜访"; UITabBarItem *visitItem = [[UITabBarItem alloc]initWithTitle:@"拜访" image:nil tag:3]; [visitItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]]; visitVC.tabBarItem = visitItem; //构建UITabBarController并指定代理为本身 self.tabBarController = [[UITabBarController alloc]init]; self.tabBarController.delegate = self; //为UITabBarController添加TabBarItem self.tabBarController.viewControllers = [NSArray arrayWithObjects:textVC,signVC,visitVC, nil]; //设置选中哪个tab [self.tabBarController setSelectedIndex:1]; self.window.backgroundColor = [UIColor whiteColor]; //指定根视图 self.window.rootViewController = self.tabBarController;