10
我想在iOS 7中嘗試setSelectedImageTintColor
,但它不起作用。下面是我在我的AppDelegate.m
下didFinishLaunchingWithOptions
setSelectedImageTintColor不能在iOS 7中工作
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