iOS UITabBartroller作为根视图

//

//  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作为导航控制器根视图了...


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值