簡體   English   中英

UITabBar圖標文字顏色

[英]UITabBar icons text color

如何更改UITabBar的文本顏色(如果重要的話,該顏色包含在UINavigationController中)? 如果我寫這個-

UITabBar.appearance().tintColor = UIColor.greenColor()

那么顏色就會如預期的那樣是綠色,但是如果我這樣寫的話-

UITabBar.appearance().tintColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0)

文字不可見

同樣的道理

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected) //red color 

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(red: CGFloat(104), green: CGFloat(154), blue: CGFloat(26), alpha: CGFloat(1))], forState:.Selected) //invisible

請嘗試這樣寫:

UITabBar.appearance().tintColor = UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0)

您必須將紅色,綠色和藍色除以255,像這樣

UIColor(red:255/255.0, green:255/255.0, blue: 255/255.0, alpha: 1.0)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM