Ios8 UITabBar淡色不适用于图像

Ios8 UITabBar淡色不适用于图像,ios8,uitabbar,uiappearance,Ios8,Uitabbar,Uiappearance,我用Interface Buider设置了一个UITabBar,只有在我没有设置全局应用程序色调颜色的情况下,图像高亮显示才能正常工作: 当我使用设置应用程序的全局着色颜色时 [[UIView appearance] setTintColor:[TAStyleKit tintColor]]; 然后,所有选项卡图像显示为选中 只有当我单击选项卡并再次返回时,它们才具有正确的颜色。请注意此处灰色的“武器”选项卡: 我做错了什么?编辑:不管我以前写了什么,看起来你只需要更改以下内容 [[UIV

我用Interface Buider设置了一个
UITabBar
,只有在我没有设置全局应用程序色调颜色的情况下,图像高亮显示才能正常工作:

当我使用设置应用程序的全局着色颜色时

[[UIView appearance] setTintColor:[TAStyleKit tintColor]];
然后,所有选项卡图像显示为选中

只有当我单击选项卡并再次返回时,它们才具有正确的颜色。请注意此处灰色的“武器”选项卡:


我做错了什么?

编辑:不管我以前写了什么,看起来你只需要更改以下内容

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

请注意,您试图更改UIView而不是UIAbbar的外观。我在一个项目中运行了这个,它成功了

Swift 4.0


uitabar.appearance()。只需将选项卡栏内UIViews上的tintColor设置为默认的灰色即可

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

不幸的是,苹果没有使用它的标准灰度值…

它也可以直接从故事板[XCode 10.1]通过设置uitabar的图像色调来设置

我每个选项卡只有一张图像,我确实希望在图像上应用色调。我删除了我写的所有内容,并编写了一个解决方案,可以满足您的要求。您设置的是UIView而不是UIAbar的外观。我在
UIView
上设置色调,因为我希望我的所有ui元素都具有此色调,而不是淡蓝色。我给您的建议虽然不是最方便的,但应该是在所有支持UIView外观的视图上设置全局色调(主要是UIView子类)。selectedImageTintColor存在一个尚未解决的已知问题,这就是您在设置UIView着色颜色时看到的问题。因此,如果您只有一个选项卡栏、导航栏、分段控件等,那么应该只在代码中添加几行。希望这对您有所帮助。
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