2014-01-08 25 views
1

我在下面的截圖中看到了選項卡的彩色標籤圖標。UITabBar'more'裏面沒有彩色圖標

enter image description here

但是當我點擊更多,查看標籤進一步,我沒有得到的彩色標籤的圖標

enter image description here

如何獲得彩色的「更多」選項卡標籤的圖標?這是我在AppDelegate中的didFinishLaunchingWithOptions

UITabBar *tb = tabBarControllerProperty.tabBar; 
     NSArray *itemsObject = tb.items; 
     for(UITabBarItem *tabItem in itemsObject) 
     { 
      UIImage *imaged = tabItem.image; 
      if([imaged respondsToSelector:@selector(imageWithRenderingMode:)]) 
      { 
       tabItem.image = [imaged imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; 
      } 
      else 
      { 
       tabItem.image = imaged; 
      } 
      tabItem.selectedImage = imaged; 

     } 
+0

你想設置更多的項目上的圖像? – iPatel

+0

不..我想設置點擊'更多'後我得到的彩色圖像圖標。參考第二張截圖。 –

回答

0

代碼試試這個,

對於設定選擇指標:

[[yourTabBarController tabBar] setSelectionIndicatorImage:[UIImage imageNamed:ImageName]]; 

有關設置標籤欄圖標,使用下面的代碼:

​​

使用這也爲其他viewControllers設置標籤欄項目。

繼續... :)

+0

如何設置彩色圖標並給出'startnew''contacts'和'logout'的圖像名稱?參考第二張截圖。我添加了[self.tabBarController.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@「img6.png」]];在類的initWithNibName中也嘗試在AppDelegate。 –

+0

您可以使用相同的標籤欄圖標。並且需要爲你的標籤欄創建一個選擇指示圖像。然後像上面那樣設置選擇指示圖像。 –

+0

以下代碼在appdelegate中不起作用 if(self.tabBarControllerProperty.selectedIndex == 4) {self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@「collaborations.png」]]; } if(self.tabBarControllerProperty.selectedIndex == 5) {self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@「contacts.png」]]; } if(self.tabBarControllerProperty.selectedIndex == 6) {self.tabBarControllerProperty.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@「logout.png」]]; } –