gpt4 book ai didi

iphone - 如何将UITableView背景设置为图像?

转载 作者:行者123 更新时间:2023-12-03 19:26:40 25 4
gpt4 key购买 nike

我注意到许多应用程序都有 UITableView 的自定义背景图像(或已将背景设置为某种颜色。)

我在 UITableView 类中找不到任何 API 来影响此问题,并且我在界面生成器中的尝试失败了(尝试设置 UIView 的颜色)

有什么建议吗?我见过有图片的第三方应用程序,所以我知道它可以做到。

最佳答案

我自己也遇到了同样的问题,但我找到了 TomSwift 提到的一种方法。正如他提到的,UITableView 有一个 backgroundView 属性,旨在执行您正在寻找的操作。如果你想设置背景颜色,你应该使用backgroundColor属性,正如其他人所说。所以:

// Set an image as the background of a UITableView called 'tableView'
UIImageView *bg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MyImage.png"]];
[tableView setBackgroundView:bg];

或者:

// Set a solid color as the background of a UITableView called 'tableView'
// In this case I chose red
[tableView setBackgroundColor:[UIColor redColor]];

关于iphone - 如何将UITableView背景设置为图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4321125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com