我正在尝试在iOS 7中设置setSelectedImageTintColor
,但它不起作用。这是我在AppDelegate.m
中的代码,在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。选中时为白色,未选中时为灰色。我做错了什么?
UIImageRenderingModeAlwaysOriginal
模式的UIImage
来解决这个问题。 - frangulyan