[ios]更改控件的背景 【转】

    1. UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"标题"  
    2.                                                         message: @"消息!"  
    3.                                                        delegate:nil   
    4.                                               cancelButtonTitle:@"取消"   
    5.                                               otherButtonTitles:@"确定",nil] autorelease];  
    6. [alert show];  
    7. UIImage *theImage = [UIImage imageNamed:@"loveChina.png"];      
    8.     theImage = [theImage stretchableImageWithLeftCapWidth:0. topCapHeight:0.];  
    9.     CGSize theSize = [theAlert frame].size;  
    10.       
    11.     UIGraphicsBeginImageContext(theSize);      
    12.     [theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];      
    13.     theImage = UIGraphicsGetImageFromCurrentImageContext();      
    14.     UIGraphicsEndImageContext();  
    15.     theAlert.layer.contents = (id)[theImage CGImage]; 
原文地址:https://www.cnblogs.com/jinjiantong/p/2965629.html