簡體   English   中英

在iOS 7中,如何更改“更多”標簽欄項目的顏色?

[英]In iOS 7, how do i change the color of the “More” tab bar item?

我可以為所有其他選項卡設置完成的選定和未選定的圖像,但不能為特殊的“更多”項目設置。

截圖

我怎樣才能做到這一點?

這是當前代碼:

[[UITabBar appearance] setTintColor:contrastColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeTextColor: contrastColor, UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]} forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeTextColor: contrastColor, UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]} forState:UIControlStateNormal];

contrastColor顏色是白色,由我們的后端系統提供。

我不知道這是否適合您,但是您可以嘗試找到一個與您使用的圖像類似的“更多”圖像,而不是使用蘋果公司的圖像(我假設您正在使用)。 如果不是,那就不要理我。

然后只需執行以下操作:

UITabBarItem *tabBarItem4 = [[tabViewController.tabBar items] objectAtIndex:3];
[tabBarItem4 setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-more-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-more-normal"]];

你嘗試過這個嗎?

tabBarController.tabBar.barTintColor = yourBarColor;

tabBarController.tabBar.tintColor = yourSelectedIconAndTextColor;

對於不同的狀態:

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:yourFontName size:yourFontSize], NSForegroundColorAttributeName: yourSelectedIconAndTextColor} forState:UIControlStateSelected];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:yourFontName size:yourFontSize], NSForegroundColorAttributeName:[UIColor defaultColor]} forState:UIControlStateNormal];

希望能幫助到你!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM