2010-06-25 123 views
2

這是我從谷歌搜索有,但顯然這不是我所需要的:添加背景圖片的UITabBarController

- (void)applicationDidFinishLaunching:(UIApplication *)application 
{  
// add the tab bar controller to the window 

[window addSubview:[tabBarController view]]; 

// load the image, create a view with the image 

NSString* dirPath = [[NSBundle mainBundle] bundlePath]; 
NSString* imageFile = [dirPath stringByAppendingString:@"homebackground.png"]; 
UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed:imageFile]]; 

[[tabBarController tabBar] addSubview: view]; 
} 

是,圖像文件加載fine..I覺得上面所做的是試圖更改標籤欄的導航欄區域的bg?我不確定。

有誰知道我會如何去改變與圖像的實際背景? 謝謝!

回答

1

嘗試使用索引通過insertSubview:atIndex:添加圖像的最下層明確0

編輯:有一個明確的了setBackgroundImage類別UITabController在這個線程:

Share background view between tabs on a UITabBarController

+0

的insertSubview:atIndex對我來說並沒有訣竅,但這是一個很好的討論,謝謝。我也在考慮在IB中添加圖像視圖併爲每個選項卡設置不同的圖像。 – RayJ 2010-06-25 20:54:38