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

swift-导航栏和tabbar(系统自带)

2015-06-17 13:47 549 查看
1,在AppDelegate.swift里面(下面这个函数里面写)

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

//定义三个视图

   var oneview = Oneview()

var twoview = Twoview()

var threeview = ThreeView()

//导航栏

var threenav : UINavigationController = UINavigationController(rootViewController: threeview)

var oneNav :UINavigationController = UINavigationController(rootViewController: oneview)

var twoNav :UINavigationController = UINavigationController(rootViewController: twoview)

//tabbar

var oneItem :UITabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.Bookmarks, tag: 0)

var twoItem :UITabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.Downloads, tag: 1)

var treeItem :UITabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.Favorites, tag: 2)

oneview.tabBarItem = oneItem

twoview.tabBarItem = twoItem

threeview.tabBarItem = treeItem

    var tc = UITabBarController()

tc.tabBar.barTintColor = UIColor.blackColor()

tc.viewControllers = [oneNav,twoNav,threenav]

self.window?.rootViewController = tc;

  return true

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