LondonGuy
LondonGuy

Reputation: 11108

UITabBarItem image colour changes to blue after first time it is selected

I'm having this issue with a UITabBar.

I have custom images I'm using for the UITabBarItems and after I select a tab the correct highlight colour shows but the original colour of the image (grey) is no longer grey. it is no blue.

So basically:

  1. I select a tab and it's highlight colour (red) shows.
  2. I now select another tab and the one I previously selected doesn't turn back to its previous colour (grey) but instead turns blue.

I have not set blue any where in the app so I think it's a default colour.

I have set the images for my UITabBar in interface builder and have modified the barTintColour in app delegate.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    let color = UIColor(red: 41.0/255.0, green: 40.0/255.0, blue: 39.0/255.0, alpha: 1.0)
    UITabBar.appearance().barTintColor = color // works
    UITabBar.appearance().tintColor = UIColor.greenColor() //does nothing

What could be doing wrong?

Here is an image of my tab bar. As you can see I've selected the camera, speech bubble and the envelope previously and currently on the settings cog wheel page. There is only one tab I haven't selected and it remains as its original colour. Which is the colour of the image. enter image description here

Would appreciate some help thanks.

Upvotes: 3

Views: 865

Answers (1)

Qazi
Qazi

Reputation: 381

You need to tell the system to keep the original rendering mode, so it does not use default colours so when you are setting the image on the tab bar. some thing like this

    barImage.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)

Upvotes: 3

Related Questions