IOS第14天(1,UITabBarController的基本的使用)

**************HMAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    
    UITabBarController *tab = [[UITabBarController alloc] init];
    self.window.rootViewController = tab;
    
    UIViewController *vc1 = [[UIViewController alloc] init];
    vc1.view.backgroundColor = [UIColor redColor];
    vc1.tabBarItem.title = @"消息";
    vc1.tabBarItem.image = [UIImage imageNamed:@"tab_recent_nor"];
//    [tab addChildViewController:vc1];
    
    UIViewController *vc2 = [[UIViewController alloc] init];
    vc2.view.backgroundColor = [UIColor redColor];
    vc2.tabBarItem.title = @"联系人";
    vc2.tabBarItem.image = [UIImage imageNamed:@"tab_buddy_nor"];

    vc2.view.backgroundColor = [UIColor greenColor];
//    [tab addChildViewController:vc2];
    
    UIViewController *vc3 = [[UIViewController alloc] init];
    vc3.view.backgroundColor = [UIColor redColor];
    vc3.tabBarItem.title = @"动态";
    vc3.tabBarItem.image = [UIImage imageNamed:@"tab_qworld_nor"];
    vc3.view.backgroundColor = [UIColor blueColor];
//    [tab addChildViewController:vc3];
    tab.viewControllers = @[vc1,vc2,vc3];
    [self.window makeKeyAndVisible];
    return YES;
}

 

转载于:https://www.cnblogs.com/ios-g/p/4763597.html

你可能感兴趣的:(IOS第14天(1,UITabBarController的基本的使用))