Zack117
Zack117

Reputation: 1075

UITabBar not changing tint color Xcode 9.3

This is very odd. My global tint is set and my icons colors are set to the default purple I have. Yet at run time its blue. Any tips? Ive checked around and have not seen anyone else with this problem.

Storyboard:

StoryBoard

Run Time:

Run Time

Upvotes: 4

Views: 2179

Answers (2)

Jeffrey
Jeffrey

Reputation: 658

I've had a similar problem, which was fixed by changing the "Render As" property to "Default" instead of "Original". You can find this in your Asset Library, when selecting your images on right right hand side under "Render As" in the attributes inspector.

Upvotes: 2

Cyan Lee
Cyan Lee

Reputation: 341

Basically, when you want to change the tint color of UITabBar programmatically, UITabBar class gives you several tint color properties:

  • tintColor: TabBarItem's color.
  • barTintColor : TabBar's background bar's color.
  • unselectedItemTintColor : color of unselected items.

so if you change the tintColor, barItems' color would be changed.


...but, Why it doesn't works on IB?

When you set a specific color to UITabBar's item in IB, there's an option named Image Tint.

imageTint

Changing a Tint option on "View" section won't affect anything to TabBar's items but only Image Tint option can change tabBar's item color.

storyboard's global tint color option changes Tint option of "View" section, but doesn't affect default value of Image Tint option, so It doesn't affect the tab bar's tint color.


So.. Why Image Tint option doesn't affected?

I can't explain why doesn't it affected. Maybe Apple had an issue with this, or kind of bug.


there are some workarounds for setting an image color :

  • Explicitly Set an Image Tint option to UITabBarController's TabBar object.

You may should set every TabBarController's Image Tint option, because it doesn't affects global setting.

  • Programmatically change global UITabBar's tintColor.

At AppDelegate.swift's didFinishLaunchingWithOptions, paste following code

UITabBar.appearance().tintColor = <#Color what you want#>

Upvotes: 9

Related Questions