码迷,mamicode.com
首页 > 其他好文 > 详细

UITabBarController

时间:2015-05-22 18:29:29      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

 UITabBarController 是标签控制器,也是多视图控制器,只不过是它管理的视图控制器没有依赖关系和层级关系,是并列关系, 所有的视图控制器都是同时存在的,空间不会释放.

 UITabBarController 也是自带一个view和显示内容以及下方的tabBar.   tabBar是一组标签,每一个标签对应一个视图控制器,点击每一个标签会进行视图控制器的切换

 

//配置viewControllers

- (void)viewDidLoad

{

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    

    //配置viewControllers

    [self configViewControllers];

}

- (void)configViewControllers

{

    //第一个

    FirstViewController *firstVC = [[FirstViewController alloc] init];

    UINavigationController *firstNC = [[UINavigationController alloc] initWithRootViewController:firstVC];

    //title

    firstNC.tabBarItem.title = @"主页";

    //image

    firstNC.tabBarItem.image = [UIImage imageNamed:@"53-house.png"];

    //badgeValue

    firstNC.tabBarItem.badgeValue = @"New";

    //设置选中的图片

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

    

    //第二个

    SecondViewController *secondVC = [[SecondViewController alloc] init];

    UINavigationController *secondNC = [[UINavigationController alloc] initWithRootViewController:secondVC];

    //title

    secondNC.tabBarItem.title = @"团购";

    //image

    secondNC.tabBarItem.image = [UIImage imageNamed:@"80-shopping-cart.png"];

    

    //第三个

    ThirdViewController *thirdVC = [[ThirdViewController alloc] init];

    UINavigationController *thirdNC = [[UINavigationController alloc] initWithRootViewController:thirdVC];

    //title

    thirdNC.tabBarItem.title = @"发现";

    //image

    thirdNC.tabBarItem.image = [UIImage imageNamed:@"12-eye.png"];

    

    //第四个

    FourthViewController *fourthVC = [[FourthViewController alloc] init];

    UINavigationController *fourthNC = [[UINavigationController alloc] initWithRootViewController:fourthVC];

    //title

    fourthNC.tabBarItem.title = @"钱包";

    //image

    fourthNC.tabBarItem.image = [UIImage imageNamed:@"35-shopping-bag.png"];

    

    //第五个

    FifthViewController *fifthVC = [[FifthViewController alloc] init];

    UINavigationController *fifthNC  = [[UINavigationController alloc] initWithRootViewController:fifthVC];

    //title

    fifthNC.tabBarItem.title = @"收藏";

    //image

    fifthNC.tabBarItem.image = [UIImage imageNamed:@"28-star.png"];

    

    //第六个

    SixthViewController *sixVC = [[SixthViewController alloc] init];

    UINavigationController *sixthNC = [[UINavigationController alloc] initWithRootViewController:sixVC];

    //title

    sixthNC.tabBarItem.title = @"工具箱";

    //image

    sixthNC.tabBarItem.image = [UIImage imageNamed:@"36-toolbox.png"];

    

    //第七个

    SeventhViewController *sevenVC = [[SeventhViewController alloc] init];

    UINavigationController *seventhNC = [[UINavigationController alloc] initWithRootViewController:sevenVC];

    //title

    seventhNC.tabBarItem.title = @"设置";

    //image

    seventhNC.tabBarItem.image = [UIImage imageNamed:@"20-gear2.png"];

    

    self.viewControllers = @[firstNC,secondNC,thirdNC,fourthNC,fifthNC,sixthNC,seventhNC];

    

    [firstNC release];

    [firstVC release];

    [secondNC release];

    [secondVC release];

    [thirdNC release];

    [thirdVC release];

}

 

UITabBarController

标签:

原文地址:http://www.cnblogs.com/mengzhaorui/p/4522772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!