UITabBarViewController

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    UITabBarController *tabBarController = [[UITabBarController alloc]init];
    
    UIViewController *vc1 = [[UIViewController alloc]init];
    
    vc1.view.backgroundColor  =[UIColor redColor];
    
    vc1.tabBarItem.title = @"消息";
    
    vc1.tabBarItem.badgeValue = @"123";
    
    
    UIViewController *vc2 = [[UIViewController alloc]init];
    
    vc2.tabBarItem.title = @"联系人";
    
    vc2.tabBarItem.badgeValue = @"123";

    vc2.view.backgroundColor  =[UIColor greenColor];
    
    UIViewController *vc3 = [[UIViewController alloc]init];
    
    vc3.view.backgroundColor  =[UIColor grayColor];
    
    vc3.tabBarItem.title = @"动态";
    
    vc3.tabBarItem.badgeValue = @"123";
    
    UIViewController *vc4 = [[UIViewController alloc]init];
    
    vc4.tabBarItem.title = @"设置";
    
    vc4.tabBarItem.badgeValue = @"123";
    
    vc4.view.backgroundColor  =[UIColor blueColor];
    
    //两种方式
//    tabBarController.viewControllers = @[vc1,vc2,vc3,vc4];
    
    [tabBarController addChildViewController:vc1];
    [tabBarController addChildViewController:vc2];

    [tabBarController addChildViewController:vc3];
    [tabBarController addChildViewController:vc4];


    
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    self.window.backgroundColor  =[UIColor redColor];
    
    self.window.rootViewController = tabBarController;
    
    [self.window makeKeyAndVisible];
    
    
    return YES;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 字符串 1.什么是字符串 使用单引号或者双引号括起来的字符集就是字符串。 引号中单独的符号、数字、字母等叫字符。 ...
    mango_2e17阅读 7,547评论 1 7
  • 《闭上眼睛才能看清楚自己》这本书是香海禅寺主持贤宗法师的人生体悟,修行心得及讲学录,此书从六个章节讲述了禅修是什么...
    宜均阅读 10,145评论 1 25
  • 前言 Google Play应用市场对于应用的targetSdkVersion有了更为严格的要求。从 2018 年...
    申国骏阅读 64,727评论 15 98
  • 第七章:理性的投资观 字数: 1.投资要围绕目的进行 投资的目的是为了挣钱。投资的除了金钱还有时间和精力也是一种投...
    幸福萍宝阅读 3,380评论 1 2
  • 本文转载自微信公众号“电子搬砖师”,原文链接 这篇文章会以特别形象通俗的方式讲讲什么是PID。 很多人看到网上写的...
    这个飞宏不太冷阅读 6,947评论 2 15