view

    //1.创建标签控制器

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


    //2.创建相应的子控制器(viewcontroller)

    FirstViewController *firstVC = [FirstViewController new];

    firstVC.navigationItem.title = @"车票预订";

    firstVC.tabBarItem.title = @"车票预订";

    firstVC.tabBarItem.image = [UIImage imageNamed:@"1@2x.png"];

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



    secondViewController *secondVC = [secondViewController new];

    secondVC.navigationItem.title = @"商旅服务";

    //设置标签名称

    secondVC.tabBarItem.title = @"商旅服务";

    //可以根据需求设置标签的的图标

    secondVC.tabBarItem.image = [UIImage imageNamed:@"2@2x.png"];

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



    thirdViewController *thirdVC = [thirdViewController new];

    thirdVC.navigationItem.title = @"订单查询";

    thirdVC.tabBarItem.title = @"订单查询";

    thirdVC.tabBarItem.image = [UIImage imageNamed:@"3@2x.png"];

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



    fourthViewController *fourthVC = [fourthViewController new];

    fourthVC.navigationItem.title = @"我的12306";

    fourthVC.tabBarItem.title = @"我的12306";

    fourthVC.tabBarItem.image = [UIImage imageNamed:@"4@2x.png"];

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


    //3.添加到控制器


    NSArray *array = @[firstNC,secondNC,thirdNC,fourthNC];

    tab.viewControllers = array;


    tab.selectedIndex=0;

    [self.navigationController presentViewController:tab animated:YES completion:nil];





}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容