view

作者: chengzigui | 来源:发表于2018-04-07 14:23 被阅读0次

    //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];

}

相关文章

网友评论

      本文标题:view

      本文链接:https://www.haomeiwen.com/subject/kalyhftx.html