static UIAlertView *alert = nil;
alert = [[UIAlertView alloc] initWithTitle:promptTitle message:promptMessage delegate:target cancelButtonTitle:cancelBtnTitle otherButtonTitles:nil];
alert.delegate = target;
alert.title = promptTitle;
alert.message = promptMessage;
for (NSString *str in otherBtnTitleArray) {
[alert addButtonWithTitle:str];
}
// [alert show];
// CGSize theSize;
//
// theSize = [alert frame].size;
//
// UIGraphicsBeginImageContext(theSize);
//
// [theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
//
// theImage = UIGraphicsGetImageFromCurrentImageContext();
//
// UIGraphicsEndImageContext();
//
// [[alert layer] setContents:(id)[theImage CGImage]];
UIImage *theImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"alert.png" ofType:nil]];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:theImage];
backgroundImageView.contentMode = UIViewContentModeScaleToFill;
[alert addSubview:backgroundImageView];
[alert sendSubviewToBack:backgroundImageView];
[alert show];
[alert release];
参考:http://stackoverflow.com/questions/6692361/custom-alertview-with-background