setSelectedImageTintColor not working in iOS 7

纵饮孤独 提交于 2019-12-01 14:33:21

问题


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]];

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


回答1:


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.

See a discussion on the Apple Developer Forums about this.

Please file a bug report with Apple.



来源:https://stackoverflow.com/questions/19306978/setselectedimagetintcolor-not-working-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!