Skip to content

Instantly share code, notes, and snippets.

@agnosticdev
Created September 21, 2015 10:51
Show Gist options
  • Save agnosticdev/516afc0903af1de4be24 to your computer and use it in GitHub Desktop.
Save agnosticdev/516afc0903af1de4be24 to your computer and use it in GitHub Desktop.
Uses Swift to create a UITabBarController and set it as the rootViewController in the AppDelegate.
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
print("here")
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let nav1 = UINavigationController()
let first = ClassNameOne(nibName: "Nib Name One", bundle: nil)
nav1.viewControllers = [first]
let second = ClassNameTwo(nibName: "Nib Name Two", bundle: nil)
let nav2 = UINavigationController()
nav2.viewControllers = [second]
let third = ClassNameThree(nibName: "Nib Name Three", bundle: nil)
let nav3 = UINavigationController()
nav3.viewControllers = [third]
let tabs = UITabBarController()
tabs.viewControllers = [nav1, nav2, nav3]
let firstImage = UIImage(named: "icon.png")
let secondImage = UIImage(named: "icon.png")
let thirdImage = UIImage(named: "icon.png")
first.tabBarItem = UITabBarItem(
title: "Title One",
image: firstImage,
tag: 1)
second.tabBarItem = UITabBarItem(
title: "Title Two",
image: secondImage,
tag:2)
third.tabBarItem = UITabBarItem(
title: "Title Three",
image: thirdImage,
tag:3)
self.window!.rootViewController = tabs;
self.window?.makeKeyAndVisible();
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment