2015-02-24 91 views
0

在用戶選擇一個選項卡之前,當視圖第一次出現時,UITabbar項目的圖像色調爲灰色(默認)。UITabbar項目圖像未正確顯示

屏幕快照視圖時出現的第一次:

screen shot when the view appear for the first time

+0

所有的tabbar圖像都是灰色的? – random 2015-02-24 15:56:43

+0

不只是未選中的一個,但用戶選擇一個標籤後,其工作完美 – UIBittu 2015-02-24 15:58:45

+0

您可以發佈屏幕截圖嗎? – random 2015-02-24 16:00:22

回答

1

我有同樣的問題,我用這個代碼插入UITabBar item解決:我將此

UITabBar *tabBar = self.tabBarController.tabBar; 
    UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0]; 
    UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1]; 
    UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2]; 

    tabBarItem1.image = [[UIImage imageNamed:@"img1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
    tabBarItem2.image = [[UIImage imageNamed:@"img2.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
    tabBarItem3.image = [[UIImage imageNamed:@"img3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 

    tabBarItem1.selectedImage = [[UIImage imageNamed:@"img1_sel.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 

代碼給我所有的視圖控制器(在我的情況3),它會創建正確的圖像,而選擇和未選中。我希望它可以幫助你

+0

雅它適合我。 – UIBittu 2015-02-24 16:49:39