【问题标题】:setSelectedImageTintColor not working in iOS 7setSelectedImageTintColor 在 iOS 7 中不起作用
【发布时间】:2013-10-10 21:59:55
【问题描述】:

我正在尝试在 iOS 7 中 setSelectedImageTintColor,但它不起作用。这是我在AppDelegate.mdidFinishLaunchingWithOptions 下的代码

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。选中时为白色;未选中时为灰色。我做错了什么?

【问题讨论】:

    标签: ios objective-c uitabbarcontroller ios7 uiappearance


    【解决方案1】:

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

    请参阅discussion on the Apple Developer Forums 了解此内容。

    请提交bug report with Apple

    【讨论】:

    • 我想你可以通过使用UIImageUIImageRenderingModeAlwaysOriginal 模式来解决这个问题。
    猜你喜欢
    • 2013-10-19
    • 2013-09-16
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多