【发布时间】:2017-03-24 14:24:39
【问题描述】:
我有几个标签的标签栏控制器。
所有选项卡项的图像和文本都应具有相同的未选择颜色。
所有选项卡项都应具有不同的图像选择颜色和 文本。
我已准备好创建具有选定和非选定项目所需颜色的图像。而且我知道如何从 AppDelegate 更改所有选项卡的颜色
UITabBar.appearance().tintColor = UIColorFromRGB(rgbValue: MY_COLOR, aplhaValue: 1.0)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColorFromRGB(rgbValue: MY_COLOR, aplhaValue: 1.0)], for: UIControlState.selected)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.white], for: UIControlState.normal)
但我想为不同的物品制作不同的颜色。
【问题讨论】:
-
结帐this post。
-
您可以直接设置图像的色调颜色,然后根据状态为其分配所需的色调。
{UIIMAGE}.tint(with: {UIColor})