setSelectedImageTintColor在iOS 7中不起作用 [英] setSelectedImageTintColor not working in iOS 7

查看:80
本文介绍了setSelectedImageTintColor在iOS 7中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iOS 7中尝试 setSelectedImageTintColor ,但它无效。这是我在 AppDelegate.m 下的代码 didFinishLaunchingWithOptions

I'm trying to setSelectedImageTintColor in iOS 7, but it's not working. Here's the code that I have in my AppDelegate.m under didFinishLaunchingWithOptions

UITabBarController *tabBarController = (UITabBarController *) self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;

for (UITabBarItem *item in tabBar.items)
    {
        UIImage *image = item.image;
        UIImage *correctImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        item.image = correctImage;
    }

[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:44.0/255.0 green:176.0/255.0 blue:28.0/255.0 alpha:1.0]];
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0]];

它仍然不会显示selectedImageTintColor。选中时它是白色的;未选中时为灰色。我做错了什么?

It still won't show the selectedImageTintColor. It's white when selected; gray when unselected. What am I doing wrong?

推荐答案

这是iOS 7中的一个已知问题。 tintColor 用于选定的标签图像。完全忽略 selectedImageTintColor 。无法对未选中的标签图像进行着色。

This is a known issue in iOS 7. The tintColor is used for the selected tab image. The selectedImageTintColor is completely ignored. There is no way to tint unselected tab images.

请参阅关于Apple开发者论坛的讨论

请提交与Apple的错误报告

这篇关于setSelectedImageTintColor在iOS 7中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆