UITableView背景图片 [英] UITableView background Image

查看:113
本文介绍了UITableView背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将png图像设置为tableview的背景.使用以下代码,一切都很好!但仅适用于iPhone Simulator.如果尝试在iPhone设备上运行该应用程序,则tableview的背景将保持白色(或清晰).您是否认为这是我尝试设置背景颜色的方式.在尝试以下操作之前,我一直在尝试多种方法,但是所有方法都存在相同的问题.

I'am trying to setup a png image as my tableview's background. With the following code all are fine! But only on iPhone Simulator. If I try to run the application on an iPhone device the background of tableview remains white (or clear). Do you thing thing that is something about the way I tried to set the background color. I have been trying many ways until the following, but all have the same issue.

self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TableViewBackground.png"]];

提前谢谢!

推荐答案

请使用以下代码.

UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TableViewBackground.png"]];
[tempImageView setFrame:self.tableView.frame]; 

self.tableView.backgroundView = tempImageView;
[tempImageView release];

谢谢

这篇关于UITableView背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆