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

给AlertView添加图片背景

时间:2016-11-17 01:35:45      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:context   erb   etc   frame   eal   cap   str   ima   graph   

UIAlertView *theAlert = [[[UIAlertViewalloc]

initWithTitle:@"Attention"

message:@"I‘m a Chinese!"delegate:nilcancelButtonTitle:@"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)];

theImage =

UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

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

给AlertView添加图片背景

标签:context   erb   etc   frame   eal   cap   str   ima   graph   

原文地址:http://www.cnblogs.com/CJH5209/p/6072137.html

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