我试图将图像设置为背景的一个UIView类型的图像,这里就是我如何做到这一点:背景“水印”的UIViewController中
UIImage *bgImage = [UIImage imageNamed:@"watermark.png"];
self.view.layer.contents = bgImage.CGImage;
self.view.backgroundColor = [UIColor clearColor];
这个工程在iOS5中,但在iOS4的我得到的是黑色的背景。有任何想法吗?
我尝试了其他方法,如colorWithPatternImage,但没有正确显示图像。
这应该工作,因为我相信,iPhone OS 2.0。确保视图具有非零大小,并且由于其他不相关的情况,图像不为零。 – Costique 2012-01-13 17:26:50