码迷,mamicode.com
首页 > 编程语言 > 详细

Swift基础之UITabBarController(这是在之前UITableView中直接添加的)

时间:2016-07-07 13:13:44      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

这些基础内容基本已经可以搭建项目框架,剩下的就是一些优化,细节和数据请求问题,慢慢更新....

在AppDelegate中创建方法

//创建方法执行UITabBarController

    func createTabBar()
    {
        let tabBarContro = UITabBarController();
        
        let viewC = ViewController();
        viewC.tabBarItem.image = UIImage(named: "item1.png");
        let oneNavigation = UINavigationController.init(rootViewController: viewC);
        
        let firstVC = FirstViewController();
        firstVC.tabBarItem.image = UIImage(named: "item2.png");
        let twoNavigation = UINavigationController.init(rootViewController: firstVC);
        
        let secondVC = SecondViewController();
        secondVC.tabBarItem.image = UIImage(named: "item3.png");
        let threeNavigation = UINavigationController.init(rootViewController: secondVC);
        
        let navArray = [oneNavigation,twoNavigation,threeNavigation];
        tabBarContro.viewControllers = navArray;
        
        window?.rootViewController = tabBarContro;

    }

点击第一个模块进入第二层界面后需要隐藏tabBar

//进入第二层界面隐藏UITabBarController

override func viewWillAppear(animated: Bool) {
        navigationController?.tabBarController?.tabBar.hidden = true;
    }
    override func viewWillDisappear(animated: Bool) {
        navigationController?.tabBarController?.tabBar.hidden = false;
    }

Swift基础之UITabBarController(这是在之前UITableView中直接添加的)

标签:

原文地址:http://blog.csdn.net/hbblzjy/article/details/51849415

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!