![](/img/trans.png)
[英]xcode 7.3 swift Access and change colors and text in a navigation bar
[英]Change the text and icon colors for UITabBar and UITabBarItems in XCODE 7 using swift 2.0?
如何使用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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.