iphone - UITableView背景图片

标签 iphone uitableview background background-color

我正在尝试设置一个 png 图像作为我的桌面 View 的背景。使用以下代码一切都很好!但仅限于 iPhone 模拟器。如果我尝试在 iPhone 设备上运行该应用程序,表格 View 的背景将保持白色(或透明)。你认为这与我尝试设置背景颜色的方式有关吗?我一直在尝试很多方法,直到出现以下方法,但都有相同的问题。

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];

谢谢

关于iphone - UITableView背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5825397/

相关文章:

ios - 具有不可满足约束的 UITableViewCell

SWIFT 4 - 通过单击 UITableView 的一项来打开 UICollectionView

iphone - objective-c : How to highlight the first cell in table view when view loads?

iphone - 如何在 ios 推送通知出现之前对其进行过滤

iphone - 使用 wav 文件和 openal 在 iPhone 上进行节拍检测

iphone - 核心数据 : Sort and Section on Relationships

ios - 从 JSON 响应中添加动态字段的最佳方式是什么

android - 背景大小 :cover not working in android native browser

jquery - 在最后一帧停止完整的背景视频

java - 设置 JTextPane 的背景会导致视觉效果 (Java)