Swift 在iOS 7中,选项卡栏中选定图像的颜色不会更改

Swift 在iOS 7中,选项卡栏中选定图像的颜色不会更改,swift,uitabbar,Swift,Uitabbar,我即将向应用商店提交我的第一个应用程序,但我遇到了一个无法解决的问题 基本上,我有一个UIPickerView,允许用户更改应用程序的颜色主题。这在iOS 8中工作得非常好,但是当我在iOS 7上运行应用程序时,在选项卡栏中设置所选图像的颜色不会改变 我使用此代码更改颜色: self.tabBarController.tabBar.selectedImageTintColor = UIColor.newPinkColor() UITabBar.appearance

我即将向应用商店提交我的第一个应用程序,但我遇到了一个无法解决的问题

基本上,我有一个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