- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible]; // 第二步:创建UITabBarController对象
self.mainTab = [[UITabBarController alloc] init]; // 第三步:设置window的根视图控制器
self.window.rootViewController = self.mainTab;
UINavigationController *loginVC = [[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc] init]];
loginVC.navigationBarHidden = YES;
[self.mainTab presentViewController:loginVC animated:NO completion:nil]; // 控制器
UINavigationController *homeNVC = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];
// 设置图片
homeNVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:[[UIImage imageNamed:@"tb_08"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tb_09"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; UINavigationController *classNVC = [[UINavigationController alloc] initWithRootViewController:[[ClassifyViewController alloc] init]];
// 设置图片
classNVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"分类" image:[[UIImage imageNamed:@"tb_05"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tb_03"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; UINavigationController *shoppingNVC = [[UINavigationController alloc] initWithRootViewController:[[ShoppingCarViewController alloc] init]];
// 设置图片
shoppingNVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"购物车" image:[[UIImage imageNamed:@"tb_06"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tb_01"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; UINavigationController *userNVC = [[UINavigationController alloc] initWithRootViewController:[[UserViewController alloc] init]];
// 设置图片
userNVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人中心" image:[[UIImage imageNamed:@"tb_07"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tb_02"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; // 将导航控制器对象添加到数组中
self.mainTab.viewControllers = @[homeNVC,classNVC,shoppingNVC,userNVC]; return YES;
}
05-11 20:20