Ios UITabBar图标文本颜色
我如何更改UITabBar的文本颜色(如果有问题,它包含在UINavigationController中)? 如果我写这个-Ios UITabBar图标文本颜色,ios,swift,Ios,Swift,我如何更改UITabBar的文本颜色(如果有问题,它包含在UINavigationController中)? 如果我写这个- UITabBar.appearance().tintColor = UIColor.greenColor() UITabBar.appearance().tintColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0) 然后颜色会像预期的那样是绿色,但是如果我写这个- UITabBar.appearanc
UITabBar.appearance().tintColor = UIColor.greenColor()
UITabBar.appearance().tintColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0)
然后颜色会像预期的那样是绿色,但是如果我写这个-
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)
请尝试这样写:
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)
你必须将红色、绿色和蓝色除以255,如下所示
UIColor(red:255/255.0, green:255/255.0, blue: 255/255.0, alpha: 1.0)