2015-07-28 63 views
0

我正在使用xcode 6.4並使用storyboard來設置標籤欄控制器項目及其圖像。在XCode中選擇TabBar項目標題和圖像6.4

問題1 - 在標籤欄項目選擇的情節提要中,已經有條形項目和圖像選擇選項。我已經在兩個區域分配了圖像,但圖像在選擇時沒有改變。只存在默認(黑色)圖像。

我已經提到Link。然後還默認(黑色)

問題2 - 在故事板中,我已經爲條形圖項目和圖像選擇分配了所有圖像,並使用了給定的代碼,則標題欄中的標題不可見。只有圖像在選擇上工作正常。

代碼 -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
// Assign tab bar item with titles 
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; 
UITabBar *tabBar = tabBarController.tabBar; 
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0]; 
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1]; 
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2]; 
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3]; 
UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4]; 

tabBarItem1.title = @"Home"; 
tabBarItem2.title = @"Search"; 
tabBarItem3.title = @"Cart"; 
tabBarItem4.title = @"Account"; 
tabBarItem5.title = @"More"; 



[tabBarItem1 setSelectedImage:[[UIImage imageNamed:@"HomeSelected.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 

[tabBarItem2 setSelectedImage:[[UIImage imageNamed:@"SearchOpened.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 

[tabBarItem3 setSelectedImage:[[UIImage imageNamed:@"CartOpened.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 

[tabBarItem4 setSelectedImage:[[UIImage imageNamed:@"ProfileOpened.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 

[tabBarItem5 setSelectedImage:[[UIImage imageNamed:@"MoreTabOpened.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 



// Change the tab bar background 
UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"]; 
[[UITabBar appearance] setBackgroundImage:tabBarBackground]; 
[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_selected.png"]]; 

// Change the title color of tab bar items 
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                [UIColor whiteColor], NSForegroundColorAttributeName, 
                nil] forState:UIControlStateNormal]; 
UIColor *titleHighlightedColor = [UIColor colorWithRed:255.0/255.0 green:109.0/255.0 blue:0.0/255.0 alpha:1.0]; 
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
                titleHighlightedColor, NSForegroundColorAttributeName, 
                nil] forState:UIControlStateHighlighted]; 
return YES; 
} 

我見過可透過iOS文件走了,也沒有找到關於這些問題的任何有用的更新。請更新我。

回答