背景“水印”为 UIViewController 键入图像
我正在尝试将图像设置为 uiview 的背景,这是我的做法:
UIImage *bgImage = [UIImage imageNamed:@"watermark.png"];
self.view.layer.contents = bgImage.CGImage;
self.view.backgroundColor = [UIColor clearColor];
这在 iOS5 中有效,但在 iOS4 上我得到的只是黑色背景。有什么想法吗?
我尝试了其他方法,例如 colorWithPatternImage,但这无法正确显示图像。
I'm trying to set an image as the background for a uiview, here's how I do it:
UIImage *bgImage = [UIImage imageNamed:@"watermark.png"];
self.view.layer.contents = bgImage.CGImage;
self.view.backgroundColor = [UIColor clearColor];
This works in iOS5, but on iOS4 all I get is a black background. Any ideas?
I tried other approaches such as colorWithPatternImage, but that doesn't get the image displayed properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将第二行修改为:
Try modifying the second line to this:
你可以试试这个。
在这种情况下,您可以管理视图层次结构并将
UIImageView
放在当前视图下。希望有帮助。You could try this.
In this case you can manage the view hierachy and put the
UIImageView
under the current view. Hope it helps.我认为一切都很好,只需将其用于您的单元格
cellForAtIndexpath
I think everything is nice and OK, just use this for your cell
cellForAtIndexpath