title: iphone UIAlertView - custom background color
body: <p>I need to customize the background color of the UIAlertView.</p>
  
  <p>I have a sample code that works perfectly on iphone 3.x, but on iphone 4 the alertview shows the default blue color.</p>
  
  <pre><code>    UIAlertView *alertView = 
   [[[UIAlertView alloc] initWithTitle:@"Alerta"
          message:msg 
            delegate:nil
         cancelButtonTitle:@"OK" 
         otherButtonTitles:nil] autorelease];
  
   [alertView show];
  
   UILabel *theTitle = [alertView valueForKey:@"_titleLabel"];
   [theTitle setTextColor:[UIColor redColor]];
  
   UILabel *theBody = [alertView valueForKey:@"_bodyTextLabel"];
   [theBody setTextColor:[UIColor whiteColor]];
  
   UIImage *theImage = [UIImage imageNamed:@"Background.png"];
   theImage = [theImage stretchableImageWithLeftCapWidth:0 topCapHeight:0];
   CGSize theSize = [alertView frame].size;
  
   UIGraphicsBeginImageContext(theSize);
   [theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
   theImage = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();
  
   [[alertView layer] setContents:(id)theImage.CGImage];
  [alertView show];
  </code></pre>