title: custom background on tabbar in storyboard
body: <p>So I have to admit, that I had this code working perfectly up until a day or so ago when I added a new view, so I'm rather frustrated at the moment.</p>
  
  <p>The setup:
  I have a storyboarded app that contains a tabbar.  In the AppDelegate, I have the following for attaching the CoreData</p>
  
  <pre class="lang-objc prettyprint-override"><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
      UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];
      GamesViewController *controller = [[navigationController viewControllers] objectAtIndex:0];
      controller.managedObjectContext = self.managedObjectContext;
  
      return YES;
  }
  </code></pre>
  
  <p>Also in the AppDelegate, I had this method that would set the standard tab background to an image of my choosing:</p>
  
  <pre class="lang-objc prettyprint-override"><code>- (void)customizeInterface {    
      UIImage* tabBarBackground = [UIImage imageNamed:@"tab_background"];
      [[UITabBar appearance] setBackgroundImage:tabBarBackground];
  }
  </code></pre>
  
  <p>So this all worked fine <em>until</em> I added another login view that precedes my tabs.  I had to change what the CoreData was initially being set too (from my tabs to my login/initializing view).  Below is the new setup of how the storyboard looks.</p>
  
  <p><img src="https://i.stack.imgur.com/ABhTl.png" alt="Here&#39;s the new setup in my storyboard"></p>
  
  <p>Now when the app loads up... the background image appears initially as before, but <em>only</em> on the first tab.  Once I click off if it, it switches to the default gradient color again.  If I go back to the first / initial tab, the background does not-reapply itself, it stays as the colored gradient.</p>
  
  <p>Here is the amended applicationDidFinishLaunching code to go along with it:</p>
  
  <pre class="lang-objc prettyprint-override"><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      //instantiate local context
      NSManagedObjectContext *context = [self managedObjectContext];
      if (!context) {
          // Handle the error.
          NSLog(@"Error: Context is null");
      }
  
      LoginViewController *rootViewController = [LoginViewController alloc];
      rootViewController.managedObjectContext = context;
  
      return YES;
  }
  </code></pre>
  
  <hr>
  
  <p>So then what I tried to do, is go into the viewDidLoad in the first VC that my tabbar loads up (GameViewController) and tried adding this to fix the problem:</p>
  
  <pre class="lang-objc prettyprint-override"><code>- (void)viewDidLoad {
      [super viewDidLoad];
      [self.tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"dock_background"]];
  }
  </code></pre>
  
  <p>That didn't work, so I also tried using the same original code that I had in my AppDelegate and that also didn't work:</p>
  
  <pre class="lang-objc prettyprint-override"><code>- (void)viewDidLoad {
      [super viewDidLoad];
      UIImage* tabBarBackground = [UIImage imageNamed:@"tab_background"];
      [[UITabBar appearance] setBackgroundImage:tabBarBackground];
  }
  </code></pre>
  
  <hr>
  
  <p>So... I'm sort of stuck.  I've got to be doing (or not doing) something so obvious... Anyone out there have any tips / pointers?</p>
  
  <p>Thanks a ton
  - Drew</p>