suer のブログ

メモメモ. はてダ → http://d.hatena.ne.jp/suer/

iOS で下バーでタブみたいなやつ

環境: iOS SDK 8.1

こういうやつ

f:id:suer:20150102213858p:plain

UITabBarController を使う。

let controller1 = UIViewController(nibName: nil, bundle: nil)
controller1.tabBarItem = UITabBarItem(tabBarSystemItem: .Favorites, tag: 1)
let controller2 = UIViewController(nibName: nil, bundle: nil)
controller2.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.Contacts, tag: 2)
let controller3 = UIViewController(nibName: nil, bundle: nil)
controller3.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.More, tag: 3)

let tabBarController = UITabBarController(nibName: nil, bundle: nil)
tabBarController.setViewControllers([controller1, controller2, controller3], animated: false)