title: Setting Background Image Programmatically In A Xib
body: <p>I have a XIB file with <code>UIControl</code> and <code>UIScrollView</code> elements inside of it. I would like to add a background image to the view. I tried adding an ImageView in IB but I could not get it to be present as a background and it obscured the control elements. Sending a <code>sendViewBack</code> message doesn't seem to do anything either.</p>
  
  <p>When I create a UIImageView programmatically, it doesn't show up.</p>
  
  <p>Below is the code I attempted:</p>
  
  <p>Programmatic Creation</p>
  
  <pre><code>UIImage *imageBackground = [UIImage imageWithContentsOfFile:@"globalbackground"];
  
  UIImageView *backgroundView = [[UIImageView alloc] initWithImage:imageBackground];
  
  [[self view] addSubview:backgroundView];
  
  [[self view] sendSubviewToBack:backgroundView];
  </code></pre>
  
  <p>Dealing with the NIB file</p>
  
  <pre><code>[[self view] sendSubviewToBack:background];
  </code></pre>
  
  <p>where background is an <code>IBOutlet</code> declared in the header file and connected to the NIB's image view in IB.</p>
  
  <p>Is there a step I'm missing here?</p>