Change background color of a UIAlertView

UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention"

message: @"I'm a Chinese!"

  delegate:nil 

  cancelButtonTitle:@"Cancel" 

  otherButtonTitles:@"Okay",nil] autorelease];

[theAlert show];

/*

for(UIView *view in [theAlert subviews]){

if(view.tag ==1){

view.backgroundColor = [UIColor greenColor];

}

}

*/

UIImage *theImage = [UIImage imageNamed:@"loveChina.png"];    

theImage = [theImage stretchableImageWithLeftCapWidth:0. topCapHeight:0.];

CGSize theSize = [theAlert frame].size;

UIGraphicsBeginImageContext(theSize);    

[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];    

theImage = UIGraphicsGetImageFromCurrentImageContext();    

UIGraphicsEndImageContext();

theAlert.layer.contents = (id)[theImage CGImage];

posted @ 2010-02-08 15:38  javawebsoa  Views(290)  Comments(0Edit  收藏  举报