2012-04-21 69 views
0

在我的應用程序中,我有選項卡欄控制器。我想要改變標籤欄圖像的默認顏色,即默認的藍色。當它選擇ios時更改tabbar圖像顏色

請注意:我不想更改標籤欄的背景顏色,但只選擇默認藍色中選定的標籤欄項目的顏色。 這裏是我的代碼:

NSArray *tabObjects=[NSArray arrayWithObjects:nav,video,about, nil]; 
tabView=[[UITabBarController alloc] init]; 
tabView.viewControllers=tabObjects; 

我在這裏看到了許多問題,搜索互聯網爲好。有人建議私人API,我不感興趣。有些人說當選項卡被選中時會放置自定義圖像。

請建議我這樣做的正確方法。

在此先感謝

回答

1

好像你需要

[[UITabBar appearance] setSelectedImageTintColor:[UIColor purpleColor]]; 

注:只與iOS> = 5

+1

工程我添加了**注**。希望你不會介意 – 2012-09-21 17:39:49

0

//設置的TabBar成圖像

[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"menubar"]]; 

//set the color of selected image color 
[[[self tabBarController] tabBar] setSelectedImageTintColor:[UIColor redColor]];