一个简单的tabBar
记得手动把ViewController继承UIViewController改成UITabBarController
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
UINavigationController*n1=[[UINavigationController alloc]initWithRootViewController:[[FirstViewController alloc]init]];
n1.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"111"image:nil tag:0];
UINavigationController*n2=[[UINavigationController alloc]initWithRootViewController:[[SecondViewController alloc]init]];
n2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"222"image:nil tag:1];
UINavigationController*n3=[[UINavigationController alloc]initWithRootViewController:[[ThirdViewController alloc]init]];
n3.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"333"image:nil tag:2];
//小红点
n3.tabBarItem.badgeValue=@"2";
self.viewControllers=@[n1,n2,n3];
self.tabBarController.selectedViewController= [self.viewControllers objectAtIndex:1];
}
@end