如何使用SWIFT 2在XCODE 7中更改UITabBar和UITabBarItems的文本和图标颜色?对于未选中的选项卡项目,默认的灰色文本看起来暗淡且难以阅读。
我希望文本和图标在不活动时为白色,并且该颜色为:#600c77(紫色)在活动时。
最佳答案
对于您的图标:
yourTabBar.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "tab_icon_normal"), selectedImage: UIImage(named: "tab_icon_seelcted"))
为您的文字:
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.YOURCOLOR()], forState:.Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.YOURCOLOR()], forState:.Selected)