iPhone的控件背景在某些时候显得单调,为此我们需要改变它. 以UIAlertView为例: UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"标题" message: @"消息!" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil] autorelease]; [alert show]; UIImage *theImage = [UIImage imageNamed:@"loveChina.png"]; theImage = [theImage stretchableImageWithLeftCapWidth:0. topCapHeight:0.]; CGSize theSize = [theAlert frame].size; UIGraphicsBeginImageContext(theSize); [theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)]; theImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); theAlert.layer.contents = (id)[theImage CGImage]; 并添加QuartzCore引用.