Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITabBar图标文本颜色_Ios_Swift - Fatal编程技术网

Ios UITabBar图标文本颜色

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的文本颜色(如果有问题,它包含在UINavigationController中)? 如果我写这个-

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)