您的位置:首页 > 移动开发 > Swift

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

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

在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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: