2013-08-29 24 views
0

我希望我的iOS5/6應用程序的標籤欄看起來就像在iOS7上不使用Xcode 5一樣。是否可以刪除這種光澤/陰影效果?我嘗試着名的-setFinishedSelectedImage:withFinishedUnselectedImage:代碼解決方案。但似乎不適合我的情況。我打得四處這些代碼,我有:如何實現iOS 7的標籤欄圖標設計iOS5/6

UIImage* icon1 = [UIImage imageNamed:@"discover_dg~iphone.png"]; 
UIImage* icon2 = [UIImage imageNamed:@"discover_lb~iphone.png"]; 

//UITabBarItem *updatesItem = [[UITabBarItem alloc] initWithTitle:@"Discover" image:icon1 tag:1]; 

UITabBar *tabBar = self.tabBarController.tabBar; 
UITabBarItem *updatesItem = [tabBar.items objectAtIndex:1]; 
updatesItem.image = icon1; 


[updatesItem setFinishedSelectedImage:icon2 withFinishedUnselectedImage:icon1]; 

[self.navigationController setTabBarItem:updatesItem]; 

第一個標籤欄圖標的屏幕已經加載了iOS6的活脫脫這與光澤效果..

enter image description here

或這與陰影效果..

enter image description here

我試圖刪除UITabBarItem的光澤效果/陰影的iOS5/6。當我點擊一個特定的圖標時,藍色的圖標將出現,當我離開時(在未選中的圖標中)它將變爲灰色,必須從起始處出現的原始圖像在屏幕加載/出現時已經出現。但不知何故,我得到了這組具有光澤的人..

enter image description here

enter image description here

或這些與陰影..

enter image description here

enter image description here

提前乾杯!

回答

1

你可以使用appereance協議,在iOS7中大多使用新功能,但從iOS5 appereance方法使你能夠做到這一點。
您只需要將tabbar的背景圖像和viewcontrollers的每個UItabbarItem從選定狀態更改爲未選中狀態(-setFinishedSelectedImage:withFinishedUnselectedImage:)。
如果您不需要爲每個VC應用不同的圖像,還有一個tint屬性。 檢查文檔here

檢查也是這個answer

+0

謝謝對於響應,但我實際上在Appdelegate.m文件中設置了我的標籤欄背景。我想出了這兩組效果;首先通過使用產生光澤的tintColor來實現,另一種方法是使用背景的白色圖像來產生陰影。還有一件事,你認爲故事板正在做這件事。我的tabController最初是在故事板中製作的。 – caribbean

+0

不知道,從來沒有使用故事板,我幾乎所有的程序。我能夠實現你所需要的爲選定和未選定的UITabbar項目設置每個單個圖像,而沒有任何陰影效果。 – Andrea

+0

在這種情況下,我猜沒人知道?這些不需要的效果只是在第一次加載後顯示出來。 – caribbean