转载自:http://www.cocoachina.com/bbs/read.php?tid-11741-toread-1.html
首先声明 ,其实并不是修改背景色,而是在背景上加了个颜色图片,嘿嘿
修改后的效果
2011-11-24更新:
随着sdk的不断更新,这个办法现在已经实效了。
谢谢65楼给出的解决办法,测试了一下,这个办法也只在模拟器上起作用
修改了一下,下面的代码能达到原来的效果
UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"
message: @"I'm a Chinese!"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Okay",nil] autorelease];
[theAlert show];
UIView *additonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, alert.frame.size.width-30, alert.frame.size.height-20)];
additonBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"loveChina.png"]];
#if TARGET_IPHONE_SIMULATOR
[theAlert insertSubview:additonBackgroundView atIndex:1];
#else
[theAlert insertSubview:additonBackgroundView atIndex:0];
#endif
[additonBackgroundView release];