swift-導覽列和tabbar(系統內建)

來源:互聯網
上載者:User

標籤:

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

}

swift-導覽列和tabbar(系統內建)

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.