2010-06-25 124 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