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();
如何将图标图像和图像背景添加到App委托中的UItabBar我找不到任何内容。
提前谢谢。
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.magentaColor()], forState:.Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected)
提前谢谢。
答案 0 :(得分:2)
UITabBarController
项在各个视图控制器tabBarItem
属性上设置:
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]