0xS*_*ina 13 iphone objective-c uikit ios
选择和取消选择选项卡时,如何指定图像的色调?
我试过这个,但它不起作用:
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
这使得所选图像色调为红色(不是绿色)和未选择的色调灰色(不是红色).
Jos*_*own 25
您可以为选定和未选定的标签栏按钮设置色调颜色,如下所示:
[[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
Run Code Online (Sandbox Code Playgroud)
第一行设置未选择的颜色 - 在此示例中为红色 - 通过设置UIView的tintColor,当它包含在标签栏中时.请注意,这仅设置未选择图像的色调 - 它不会更改其下方文本的颜色.
第二行将标签栏的所选图像色调颜色设置为绿色.
您使用图像的模板版本吗?
不要使用 设置图像[UIImage imageNamed: @"MyImage"],而是使用 设置图像[[UIImage imageNamed: @"MyImage"] imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate]。
此设置以及您的代码应该可以解决此问题。
| 归档时间: |
|
| 查看次数: |
9195 次 |
| 最近记录: |