0

I created a UITabBarController with storyboard for iOS5. I don't have the UITabBar declared in my ViewController and I can't set background image for tab bar.

UIImage *tabBackground = [[UIImage imageNamed:@"tabBarBackground.jpg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
// Set background for all UITabBars
[[UITabBar appearance] setBackgroundImage:tabBackground];
// Set background for only this UITabBar
[[tabBarController tabBar] setBackgroundImage:tabBackground];
Till
  • 27,559
  • 13
  • 88
  • 122
user1625435
  • 153
  • 8

1 Answers1

1

You'll need to designate tabBarController as an IBOutlet property

@property (nonatomic, strong) IBOutlet UITabBarController *tabBarController;

Then wire them up in the Connections inspector in Interface Builder, and you'll be able to use your code as shown.

enter image description here

Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • This is correct, without an outlet to the UI component you want to change, you won't be able to change it. – Daniel Dec 08 '12 at 15:59