标签栏中所选图像的颜色在iOS 7中没有变化

问题描述:

我即将提交我的第一个应用程序到应用程序商店但是我有一个问题,我无法弄清楚如何解决。标签栏中所选图像的颜色在iOS 7中没有变化

基本上,我有一个UIPickerView,允许用户更改应用程序的颜色主题。这在iOS 8中绝对正常,但是当我在iOS 7上运行应用程序时,在选项卡栏中设置选定图像的颜色不会改变。

我使用这个代码更改颜色:

 self.tabBarController.tabBar.selectedImageTintColor = UIColor.newPinkColor() 
     UITabBar.appearance().selectedImageTintColor = UIColor.newBlueColor() 

您需要使用UIImageRenderingMode.AlwaysOriginal 更改所选标签颜色以下是你可以做什么。

var tabIcon : UIImage = UIImage(named: "youImage.png")! //Initialize Image 

var tabIcon : UITabBarItem = self.tabBar.items![0] as UITabBarItem //Select tab bar item 

tabIcon.selectedImage = profileIcon.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) //It will render image to its original color