导航栏+tabBar的使用

UITabBarController *tabBarCtrl = [[UITabBarController alloc]init]; 

tabBarCtrl.tabBar.backgroundColor = [UIColor whiteColor]; 

tabBarCtrl.tabBar.tintColor = [UIColor colorWithRed:30/225.0 green:230/255.0 blue:5/255.0 alpha:0.8];  

UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:tabBarCtrl]; 

self.window.rootViewController = nav;  

//创建子控制器 

mainViewController *mainVC = [[mainViewController alloc]init]; 

mainVC.tabBarItem.title = @"急救报警"; 

mainVC.tabBarItem.image = [UIImage imageNamed:@".png"]; 

mainVC.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.9]; 

mainVC.tabBarItem.selectedImage = [UIImage imageNamed:@".png"];  

UIViewController *VC2 = [[UIViewController alloc]init]; 

VC2.tabBarItem.title = @"爱心定制"; 

VC2.tabBarItem.image = [UIImage imageNamed:@".png"];  

UIViewController *VC3 = [[UIViewController alloc]init]; 

VC3.tabBarItem.title = @"亲情报告"; 

VC3.tabBarItem.image = [UIImage imageNamed:@".png"];  

mineViewController *mineVC = [[mineViewController alloc]init]; 

mineVC.tabBarItem.title = @"我的"; 

mineVC.tabBarItem.image = [UIImage imageNamed:@".png"];  

tabBarCtrl.viewControllers = @[mainVC,VC2,VC3,mineVC];

你可能感兴趣的:(导航栏+tabBar的使用)