title: How to set the Background image for UIAlert view in iPhone?
body: <p>I want to set the custom image as background for alert view.If i set the image view frame size as static, then it displayed properly. But i have passed the message contents are dynamically displayed, so some times the contents is small and some times it comes huge amount of data displayed in the alert view.So how can i set the image view frame size which depends on the alert view frame size. </p>
  
  <p>Here my sample code,</p>
  
  <pre><code>   UIAlertView *notesAlert = [[UIAlertView alloc] initWithTitle:@"" message:notes delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
  
     UIImage *alertBoxImage = [UIImage imageNamed:@"AlertViewBG.png"];
  
     UIImageView *_backgroundImageView = [[UIImageView alloc] initWithImage:alertBoxImage];
  
     _backgroundImageView.frame = CGRectMake(0, 0, 282, 130);
  
     _backgroundImageView.contentMode = UIViewContentModeScaleToFill;
  
     [notesAlert addSubview:_backgroundImageView];
  
     [notesAlert sendSubviewToBack:_backgroundImageView]; 
  
     NSLog(@"The Alert view frame height %f and width %f", notesAlert.frame.size.height, notesAlert.frame.size.width); 
  
       // height 0.000000 and width 0.000000
  
     [notesAlert show]; 
  
     NSLog(@"After showing the Alert view frame height %f and width %f", notesAlert.frame.size.height, notesAlert.frame.size.width); 
  
      // height 173.800003 and width 312.399994
  </code></pre>
  
  <p>see my screen shot:</p>
  
  <p><img src="https://i.stack.imgur.com/Zs18H.png" alt="image"></p>
  
  <p>So how to set the image frame size which depends on the alert view frame?
  Please Help me out.
  Thanks.</p>