码迷,mamicode.com
首页 > 其他好文 > 详细

更改AlertView背景

时间:2015-02-13 19:56:00      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:

UIAlertView *theAlert = [[[UIAlertViewalloc] initWithTitle:@"Atention"  
                                                     message: @"I‘m a Chinese!"  
                                                    delegate:nil   
                                            cancelButtonTitle:@"Cancel"   
                                            otherButtonTitles:@"Okay",nil] autorelease];  
   [theAlert show];  
   UIImage *theImage = [UIImageimageNamed:@"loveChina.png"];     
   theImage = [theImage stretchableImageWithLeftCapWidth:0topCapHeight:0];  
   CGSize theSize = [theAlert frame].size;  
    UIGraphicsBeginImageContext(theSize);      
   [theImage drawInRect:CGRectMake(5, 5, theSize.width-10, theSize.height-20)];// 这个地方的大小要自己调整,以适应 alertview 的背景颜色的大小。  
   theImage = UIGraphicsGetImageFromCurrentImageContext();     
UIGraphicsEndImageContext();  
   theAlert.layer.contents = (id)[theImage CGImage];

 

更改AlertView背景

标签:

原文地址:http://www.cnblogs.com/yunis/p/4290769.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!