2012-11-20 52 views
0

我從模板中選擇了基於標籤欄的應用程序。在我需要設置的自定義圖像我試圖像下面需要在iphone中設置tabbar圖片?

UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease]; 
UINavigationController *view1=[[UINavigationController alloc]initWithRootViewController:viewController1]; 

UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease]; 
UINavigationController *view2=[[UINavigationController alloc]initWithRootViewController:viewController2]; 

UIViewController *viewController3 = [[[SecondViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil] autorelease]; 
UINavigationController *view3=[[UINavigationController alloc]initWithRootViewController:viewController3]; 

UIViewController *viewController4 = [[[SecondViewController alloc] initWithNibName:@"MainViewController" bundle:nil] autorelease]; 
UINavigationController *view4=[[UINavigationController alloc]initWithRootViewController:viewController4]; 


self.tabBarController = [[[UITabBarController alloc] init] autorelease]; 
self.tabBarController.delegate=self; 


self.tabBarController.viewControllers = [NSArray arrayWithObjects:view1,view2,view3,view4, nil]; 

[self.tabBarController.tabBarItem setImage:[UIImage imageNamed:@"h.png"]]; 

另一種方式給我試圖

[[_tabBarController tabBar] setBackgroundImage:[UIImage imageNamed:@"h.png"]]; 

在第二種方式有圖像應用,但是它是一個背景。

所以我個人需要一個像家按鈕類似的東西....

如何設置這個... 感謝....

+0

是你的問題解決了嗎? – Rajneesh071

回答

0

您的集imagesUIViewControllers'sTabBarItems如..

viewcontroller1.tabBarItems.image = [UIImage imageNamed:@"your image1"]; 

viewController2.tabBarItems.image = [UIImage imageNamed:@"your image2"]; 

viewController3.tabBarItems.image = [UIImage imageNamed:@"your image3"]; 

viewController3.tabBarItems.image = [UIImage imageNamed:@"your image3"]; 
0

你可以這樣做,

NSArray *tabs = tabBarController.viewControllers; 
    UIViewController *tab1 = [tabs objectAtIndex:0]; 
    tab1.tabBarItem.image = [UIImage imageNamed:@"clockicon.png"]; 
    UIViewController *tab2 = [tabs objectAtIndex:1]; 
    tab2.tabBarItem.image = [UIImage imageNamed:@"nearest.png"]; 
相關問題