Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting a background image for a tabbar
    primarykey
    data
    text
    <p>I'm trying to programmatically set the background image for a tabbar in my app. My code is as follows:</p> <p>RootViewController.h</p> <pre><code>IBOutlet UITabBar *mainTabBar; IBOutlet UITabBarItem *settingsBarItem; IBOutlet UITabBarItem *infoBarItem; IBOutlet UITabBarItem *aboutBarItem; </code></pre> <p>RootViewController.m</p> <pre><code>-(void)viewDidLoad { UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"smallMenuBackground.png"]]; [mainTabBar insertSubview:imageView atIndex:0]; [imageView release]; [super viewDidLoad]; } </code></pre> <p>This is not working for me. </p> <p><em>UPDATE</em></p> <p>UPDATE 23rd January 2012</p> <p>Ok, I've made a bit of progress. This only stopped working since I upgraded to Xcode 4.2 and IOS5. I managed to get it back using the options in Interface Builder, but now it only works for IOS5. Ideally I would have liked to get working programatically but I'll settle for the IB solution for now.</p> <p>I just can't seem to get it working for any previous releases.</p> <p>NOTE: my TabBar is only on my RootViewController, which is the main screen of my app.</p> <p>Ideally, if I could get the code working that Nithin suggested, that would be great:</p> <pre><code>UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabBG.png"]]; if ([[[UIDevice currentDevice] systemVersion] floatValue] &gt; 4.9) { //iOS 5 [self.tabBarController.tabBar insertSubview:imageView atIndex:1]; } else { //iOS 4.whatever and below [self.tabBarController.tabBar insertSubview:imageView atIndex:0]; } [imageView release]; </code></pre> <p>Any help would be appreciated.</p> <p>Regards, Stephen</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload