Ios4 UIAlertView背景图像

Ios4 UIAlertView背景图像,ios4,Ios4,如何在UIAlertView中以编程方式设置背景图像?没有为AlertView设置背景图像的方法。我们需要将图像设置为警报视图的子视图 试着这样做,它会起作用: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message 1......\nMessage 2......" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

如何在UIAlertView中以编程方式设置背景图像?

没有为AlertView设置背景图像的方法。我们需要将图像设置为警报视图的子视图

试着这样做,它会起作用:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message 1......\nMessage 2......" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

UIImageView *Image =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ImageName"]];
[alert addSubview:Image];

[Image release];

[alert show];
[alert release];

消息1…\n和消息2…\n如何?如果我想显示来自2变量的消息1和消息2怎么办?抱歉,我不明白您在说什么(没问题..我想办法…我想用不同的行显示每条消息。只是“\n”对我有用…谢谢你的帮助
 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:@"Empty data not Allowed" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];



   UIImage *alertImage = [UIImage imageNamed:@"custom-dialog-background.png"];

   UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:alertImage];

   backgroundImageView.frame = CGRectMake(0, 0, 282, 130);

   backgroundImageView.contentMode = UIViewContentModeScaleToFill;

   [alert addSubview:backgroundImageView];

   [alert sendSubviewToBack:backgroundImageView];


   [alert show];