Reputation: 576
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var nav1 = UINavigationController()
var first = ViewController(nibName: nil, bundle: nil)
nav1.viewControllers = [first]
var second = ccDiscovery(nibName: nil, bundle: nil)
var nav2 = UINavigationController()
nav2.viewControllers = [second]
var third = ccPosting(nibName: nil, bundle: nil)
var nav3 = UINavigationController()
nav3.viewControllers = [third]
var fourth = ccProfile(nibName: nil, bundle: nil)
var nav4 = UINavigationController()
nav4.viewControllers = [fourth]
var tabs = UITabBarController()
tabs.viewControllers = [nav1, nav2,nav3,nav4]
self.window!.rootViewController = tabs;
self.window?.makeKeyAndVisible();
How to add icon image and image background to the UItabBar
in App delegate? I couldn't find any.
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.magentaColor()], forState:.Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected)
Upvotes: 1
Views: 1469
Reputation: 1240
UITabBarController
items are set on the individual view controllers tabBarItem
property:
var tabs = UITabBarController()
nav1.tabBarItem.image = UIImage(named: "some-image-1")
nav2.tabBarItem.image = UIImage(named: "some-image-2")
nav3.tabBarItem.image = UIImage(named: "some-image-3")
nav4.tabBarItem.image = UIImage(named: "some-image-4")
tabs.viewControllers = [nav1, nav2, nav3, nav4]
Upvotes: 2