[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]; 
posted @ 2013-03-18 11:16  金建彤  阅读(154)  评论(0编辑  收藏  举报