给AlertView添加图片背景
Posted 华少不思议
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了给AlertView添加图片背景相关的知识,希望对你有一定的参考价值。
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添加图片背景的主要内容,如果未能解决你的问题,请参考以下文章