gpt4 book ai didi

ios - 将 UITableViewCell 的背景颜色设置为图案图像

转载 作者:行者123 更新时间:2023-11-28 22:02:20 24 4
gpt4 key购买 nike

我有以下代码将 UITableViewCell 的背景设置为图案图像:

UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"TestPattern"]];
cell.backgroundColor = color;

这有效并显示了背景图案,但图案奇怪地重叠:

enter image description here

我认为这是因为 UITableViewCell 实际上设置了标签的背景颜色和它包含的其他 View 及其主视图。如何让背景颜色不重叠?

最佳答案

I think this is because the UITableViewCell is actually setting the background color of the labels

正确,解释得很好。所以你必须单独设置标签的背景颜色为clearColor。这并不容易,因为根据 iOS 的版本,运行时会尝试为您重新设置它;例如,在 iOS 4 中,有必要在 willDisplayCell 中执行此操作,但在 iOS 6 中,只要您执行此操作,您就可以在 cellForRow 中执行此操作设置背景颜色之后。

关于ios - 将 UITableViewCell 的背景颜色设置为图案图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24847551/

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