2013-10-10 57 views
10

我想在iOS 7中嘗試setSelectedImageTintColor,但它不起作用。下面是我在我的AppDelegate.mdidFinishLaunchingWithOptionssetSelectedImageTintColor不能在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代碼。選中時爲白色;灰色時未選中。我究竟做錯了什麼?

回答

15

這是iOS 7中的一個已知問題。tintColor用於選定的選項卡圖像。 selectedImageTintColor完全被忽略。沒有辦法對未選中的標籤圖像着色。關於此,請參閱discussion on the Apple Developer Forums。請撥打bug report with Apple

+0

我想你可以通過在UIImageRenderingModeAlwaysOriginal模式下使用'UIImage'來解決這個問題。 – frangulyan

相關問題