//
// RootViewController.m
// UITabBarCOntrollerDemo
//
// Created by Dubai on 14/10/4.
// Copyright (c) 2015年 DUbai. All rights reserved.
//
#import "RootViewController.h"
#import "HomeViewController.h"
#import "FindViewController.h"
#import "CategoryViewController.h"
#import "ShoppingViewController.h"
#import "UserViewController.h"
#import "SettingViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
-(void)viewWillAppear:(BOOL)animated
{
[superviewWillAppear:animated];
self.navigationController.navigationBar.translucent = NO;
self.title =@"123";
}
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColorgreenColor];
//首页
HomeViewController *homeVc = [[HomeViewControlleralloc] init];
UINavigationController *homeNC = [[UINavigationControlleralloc] initWithRootViewController:homeVc];
homeNC.tabBarItem.title =@"首页";//53
homeNC.tabBarItem.image = [UIImageimageNamed:@"53-house.png"];//用在标签上的图片不呢过随便给,必须30*30高清屏 60 *60 (可以有浮动 27 *27 55 * 55 62*62)
homeNC.tabBarItem.badgeValue =@"12";//提示信息
//分类
CategoryViewController *categoryVC = [[CategoryViewControlleralloc] init];
UINavigationController *categoryNC = [[UINavigationControlleralloc] initWithRootViewController:categoryVC];
categoryNC.tabBarItem.title =@"分类";//06
categoryNC.tabBarItem.image = [UIImageimageNamed:@"06-magnifying-glass.png"];
//发现
FindViewController *findVC = [[FindViewControlleralloc] init];
UINavigationController *findNC = [[UINavigationControlleralloc] initWithRootViewController:findVC];
findNC.tabBarItem.title =@"发现";//12
findNC.tabBarItem.image = [UIImageimageNamed:@"12-eye.png"];
// findNC.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:(UITabBarSystemItemSearch) tag:0];//可以自定义标签(系统的自带图片)
//购物车
ShoppingViewController *shopVC = [[ShoppingViewControlleralloc] init];
UINavigationController *shopNC = [[UINavigationControlleralloc] initWithRootViewController:shopVC];
shopNC.tabBarItem.title =@"购物车";//80
shopNC.tabBarItem.image = [UIImageimageNamed:@"80-shopping-cart.png"];
//用户
UserViewController *userVC =[[UserViewControlleralloc] init];
UINavigationController *userNC =[[UINavigationControlleralloc] initWithRootViewController:userVC];
userNC.tabBarItem.title =@"我的";//22
userNC.tabBarItem.image = [UIImageimageNamed:@"22-skull-n-crossbones.png"];
//设置
SettingViewController *setVC = [[SettingViewControlleralloc] init];
UINavigationController *setNV = [[UINavigationControlleralloc] initWithRootViewController:setVC];
setNV.tabBarItem.title =@"设置";
setNV.tabBarItem.image = [UIImageimageNamed:@"19-gear.png"];//默认是五个.其他的隐藏
//将创建的controller添加到tabBarController中管理(模块添加)
//标签设置的图片背景透明(镂空中间扣掉,看到的蓝色是透过来的蓝色)
self.viewControllers =@[homeNC,categoryNC,findNC,shopNC,userNC,setNV];
//标签栏的颜色
self.tabBar.barTintColor = [UIColorgreenColor];//可以统一设置
//tabVC.tabBar.backgroundColor = [UIColor redColor];
self.tabBar.tintColor = [UIColorredColor];//被选中的标签的颜色
//tabVC.tabBar.backgroundImage = [UIImage imageNamed:@"he.png"];//320 *49
self.selectedIndex =2;//设置首先被选择的标签.
//tabVC.tabBar.backgroundImage = [UIImage imageNamed:@"he.png"];//标签栏设置背景图片
//UIAppearance协议提供统一设置的方法
//不是所有属性都支持统一设置,tintColor就不支持.
//[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
//[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"ni.png"] forBarMetrics:(UIBarMetricsDefault)];
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
切记:
不要 再把UITabBarController作为导航控制器根视图了...