[英]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.