美文网首页
创建底部标签控制器

创建底部标签控制器

作者: 26aa4a305186 | 来源:发表于2018-11-22 21:30 被阅读0次

    #import "ViewController.h"

    #import "oneViewController.h"

    #import "twoViewController.h"

    #import "threeViewController.h"

    #import "fourViewController.h"

    #import "fiveViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        // Do any additional setup after loading the view, typically from a nib.

    //首先初始化controller

        oneViewController *one = [oneViewController new];

    //创建第一个

        UINavigationController *oneNav = [[UINavigationController alloc]initWithRootViewController:one];

        oneNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"今日特卖" image:[UIImage imageNamed:@"aa"] selectedImage:[UIImage imageNamed:@"aa"]];

    //第二个

        twoViewController *two = [twoViewController new];

        UINavigationController *twoNav = [[UINavigationController alloc]initWithRootViewController:two];

        twoNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"社区" image:[UIImage imageNamed:@"bb"] selectedImage:[UIImage imageNamed:@"bb"]];

    //第三个

        threeViewController *three = [threeViewController new];

        UINavigationController *threeNav = [[UINavigationController alloc]initWithRootViewController:three];

        threeNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"升级权益" image:[UIImage imageNamed:@"cc"] selectedImage:[UIImage imageNamed:@"cc"]];

    //第四个

        fourViewController *four = [fourViewController new];

        UINavigationController *fourNav = [[UINavigationController alloc]initWithRootViewController:four];

        fourNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"购物车" image:[UIImage imageNamed:@"dd"] selectedImage:[UIImage imageNamed:@"dd"]];

    //第五个

        fiveViewController *five = [fiveViewController new];

        UINavigationController *fiveNav = [[UINavigationController alloc]initWithRootViewController:five];

        fiveNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"个人中心" image:[UIImage imageNamed:@"ee"] selectedImage:[UIImage imageNamed:@"ee"]];

        self.viewControllers=@[oneNav,twoNav,threeNav,fourNav,fiveNav];

    }

    @end

    相关文章

      网友评论

          本文标题:创建底部标签控制器

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