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

UITabBarController 初学

时间:2014-05-15 02:16:10      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   c   

纯代码编写UITabBarController, 不多说,直接见代码

bubuko.com,布布扣
RViewController1 *vc1 = [[RViewController1 alloc]init];
    
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:vc1];
    //只赋值 tabBarItem.title, 通过.title属性取值是取不到值
    //navController.tabBarItem.title = @"Page 1";
    
    //相当于对tabBarItem.title  和 navigationItem.title同时赋值
    navController.title = @"Page 1";
    navController.tabBarItem.image = [UIImage imageNamed:@"1.jpg"];
    
    RViewController2 *vc2 = [[RViewController2 alloc]init];
    vc2.title =@"Page 2";
//    UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"Page 2" image:[UIImage imageNamed:@"2.png" ] selectedImage:[UIImage imageNamed:@"2_pressed.png"]];
    vc2.tabBarItem.image = [UIImage imageNamed:@"2.png"];
    
    RViewController3 *vc3 = [[RViewController3 alloc]init];
    vc3.title =@"Page 3";
    vc3.tabBarItem.image = [UIImage imageNamed:@"3.png"];
    
    RViewController4 *vc4 = [[RViewController4 alloc]init];
    vc4.title =@"Page 4";
    vc4.tabBarItem.image = [UIImage imageNamed:@"4.png"];
    vc4.tabBarItem.badgeValue = @"10";
    
    RViewController5 *vc5 = [[RViewController5 alloc]init];
    
    //创建 UITabItem的实例
    UITabBarItem *item1 = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemHistory tag:0];
    vc5.tabBarItem = item1;
    
    NSArray *controllers = [NSArray arrayWithObjects:navController,vc2,vc3,vc4, nil];
    
    UITabBarController *tabController = [[UITabBarController alloc]init];
    tabController.viewControllers = controllers;
    
    self.window.rootViewController = tabController;
bubuko.com,布布扣

 

UITabBarController 初学,布布扣,bubuko.com

UITabBarController 初学

标签:style   blog   class   code   java   c   

原文地址:http://www.cnblogs.com/mlgblog/p/3728753.html

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