title: How to set background image of a view?
body: <p>I am a beginner at Obj-C/Cocoa Touch/iPhone OS.</p>
  
  <p>I wish to have a background for my app with different images everytime the the view is called.</p>
  
  <p>Say I have 10 images. I 've used it like this:</p>
  
  <pre><code>//random image generation
  NSString* imageName;
  int aRandomNumber = arc4random() % 10;
  imageName =[NSString stringWithFormat:@"g%d.jpg",aRandomNumber]; 
  self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imageName]]];
  NSLog(@"aRandomNumber is %d", aRandomNumber);
  //random image is generated
  </code></pre>
  
  <p>Its working fine</p>
  
  <ul>
  <li>Now, say I have text labels on my view and the text isn't displaying correctly due to image colors.
  How can I make it a little transparent? (I guess in Interface Builder its called alpha.)</li>
  <li>Say my image isn't 320x480. How do I set it to fill the entire view?</li>
  </ul>
  
  <p>How can I do it with UIView/UIImageView?</p>
  
  <p>I found <code>initWithHue:saturation:brightness:alpha:</code> in the documentation but it's not working:</p>
  
  <pre><code>self.view.backgroundColor = [[UIColor alloc] initWithHue:0.0 saturation:1.0 brightness:1.0 alpha:1.0];
  </code></pre>
  
  <p>Please Help!</p>
  
  <hr>
  
  <p>A friend suggested........ </p>
  
  <pre><code>self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:imageName]]];
  </code></pre>
  
  <p>..........he told it's more efficient because it doesn't save the image in the cache.</p>