2013-09-16 54 views
1

如何爲每個UITabBarItem設置自定義字體。我發現的全部是[[UITabBarItem appearance] setTitleTextAttributes:...]但它爲所有選項卡設置相同的屬性。 我想爲每個UITabBarItem設置屬性,它必須是自定義的。 像[tabBarItem setTitleTextAttributes:forState:]這樣的方法不起作用。如何爲UITabBarItem設置自定義標題屬性

+0

'[self.tabBarItem setTitleTextAttributes:forState:]'成功地改變了我的文本風格。你是說你想讓每個標籤的文字風格都不一樣嗎? – hgwhittle

+0

是的。但是你的方法對我不起作用。我不知道爲什麼。 – dpart

+0

http://stackoverflow.com/questions/6051706/uitabbaritem-with-custom-title-color-and-images你可以使用它。 –

回答

0

使用的形象,如果你想做到這一點沒有,這是不可能的 閱讀每UITabBarItem分別然後用圖像的每一個

UITabBarController *tabBarController=(UITabBarController*)self.window.rootViewController; 

UITabBar *tabBar=tabBarController.tabBar; 

UITabBarItem *tabBarItemClassic=[tabBar.items objectAtIndex:0]; 

UITabBarItem *tabBarItemAdvance=[tabBar.items objectAtIndex:1]; 

UITabBarItem *tabBarItemMore=[tabBar.items objectAtIndex:2]; 

現在可以說,我想用不同的顏色tabBarItemMore。

您可以標題爲零,並可以使用自定義設計的圖像顯示在那裏。

在我下面的情況下,我不使用標題我正在使用的圖像,其標題下方的圖標。

[tabBarItemMore setImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 

    [tabBarItemMore setSelectedImage:[[UIImage imageNamed:@"more.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 
相關問題