UITabBar hue color does not work with images

I have UITabBarconfigured it using the Builder interface, and the image highlighting works correctly only if I do not set the hue color of the global application:

tab bar without tint color

When I set the global hue color of my application using

[[UIView appearance] setTintColor:[TAStyleKit tintColor]];

then all tab images are displayed as selected.

enter image description here

Only when I click on the tab and go back do they have the correct color. Notice the Weapons tab, which is gray here:

enter image description here

What am I doing wrong?

+4
source share
3 answers

EDIT: , , , ...

[[UIView appearance] setTintColor:[TAStyleKit tintColor]];

, ...

[[UITabBar appearance] setTintColor:[TAStyleKit tintColor]];

, UIView, UITabBar. , .

enter image description here

enter image description here

Swift 4.0

UITabBar.appearance().tintColor = UIColor.red TAStyleKit.tintColor

+10

, UIView.tintColor. tintColor UIViews .

let view = UIView.appearance()
view.tintColor = UIColor.redColor()

let viewsInTabBar = UIView.appearanceWhenContainedInInstancesOfClasses([UITabBar.self])
viewsInTabBar.tintColor = UIColor(white: 144.0 / 255.0, alpha: 1) // default gray for inactive items

let tabBar = UITabBar.appearance()
tabBar.tintColor = UIColor.redColor() // actual highlight color

, ...

+5

Storyboard [XCode 10.1], Image Tint UITabBar enter image description here

0

Source: https://habr.com/ru/post/1570074/


All Articles