Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2623223
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5921
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: iOS平台

2015-10-10 20:15:01

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

         //1.创建Window

         self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

         self.window.backgroundColor = [UIColor whiteColor];

    

        //a.初始化一个tabBar控制器

         UITabBarController *tb=[[UITabBarController alloc]init];

         //设置控制器为Window的根控制器

         self.window.rootViewController=tb;

    

        //b.创建子控制器

         UIViewController *c1=[[UIViewController alloc]init];

         c1.view.backgroundColor=[UIColor grayColor];

         c1.view.backgroundColor=[UIColor greenColor];

         c1.tabBarItem.title=@"消息";

         c1.tabBarItem.image=[UIImage imageNamed:@"tab_recent_nor"];

         c1.tabBarItem.badgeValue=@"123";

    

         UIViewController *c2=[[UIViewController alloc]init];

         c2.view.backgroundColor=[UIColor brownColor];

         c2.tabBarItem.title=@"联系人";

         c2.tabBarItem.image=[UIImage imageNamed:@"tab_buddy_nor"];

    

         UIViewController *c3=[[UIViewController alloc]init];

         c3.tabBarItem.title=@"动态";

         c3.tabBarItem.image=[UIImage imageNamed:@"tab_qworld_nor"];

    

         UIViewController *c4=[[UIViewController alloc]init];

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

         c4.tabBarItem.image=[UIImage imageNamed:@"tab_me_nor"];

    

    

         //c.添加子控制器到ITabBarController中

         //c.1第一种方式

         [tb addChildViewController:c1];

         [tb addChildViewController:c2];

         [tb addChildViewController:c3];

         [tb addChildViewController:c4];

    

         //c.2第二种方式

         //tb.viewControllers=@[c1,c2,c3,c4];

    

    

        tb.selectedIndex = 2;

    

         //2.设置Window为主窗口并显示出来

         [self.window makeKeyAndVisible];

         return YES;

}

阅读(782) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~