2011-10-11 63 views
0

我想在UITabbar上實現下面的附加圖像。自定義UITabBar擴展選擇

http://i.imgur.com/7Tukx.png

它是非常簡單的,在選擇的標籤與標籤來顯示另一個選項卡上的文字和選擇拓展,所選擇的選項卡會崩潰。

我不知道如何用UItabbar來做到這一點。

如果有人能指出我正確的方向,我將不勝感激。

+0

也許澄清一點基本上圖像右側的選項卡已被選中。而左邊的那個沒有被選中。在選中該選項卡時,它應該展開並縮小其餘選項卡,並顯示包含當前選項卡文本的標籤,例如「設置」 – lancegoh

回答

0

我不完全確定你在做什麼,但我認爲this可能與你有關。您可以使用基本概念並將其調整爲您所需的。

1

對於自定義選項卡,您在appdelegate類中使用此方法 此方法創建兩個選項卡欄項目。 和你設置你的圖像..

-(void)SetTabs 
{ 

tabBarController = [[UITabBarController alloc]init]; 

NSMutableArray *localControllerArray = [[NSMutableArray alloc]initWithCapacity:2]; 


UIImage *image = [UIImage imageNamed:@"home.png"]; 
GreetingCardsViewController *GreetingCardsView = [[[GreetingCardsViewController alloc] initWithNibName:@"GreetingCardsViewController" bundle:nil] autorelease]; 
UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:@"Home" image:image tag:0]; 
UINavigationController *GreetingCardsViewNavigationController = [[UINavigationController alloc]initWithRootViewController:GreetingCardsView]; 
GreetingCardsView.tabBarItem = item; 
[localControllerArray addObject:GreetingCardsViewNavigationController]; 


UIImage *image1 = [UIImage imageNamed:@"heart1.png"]; 
Cards *CardView = [[[Cards alloc] initWithNibName:@"Cards" bundle:nil] autorelease]; 
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"Cards" image:image1 tag:1]; 
UINavigationController *CardNavigationController = [[UINavigationController alloc]initWithRootViewController:CardView]; 
CardNavigationController.tabBarItem = item1; 
[localControllerArray addObject:CardNavigationController]; 
[tabBarController setViewControllers:localControllerArray]; 
[_window addSubview:tabBarController.view]; 
[localControllerArray release]; 
}