gpt4 book ai didi

objective-c - 设置自定义 tableviewCell 的背景

转载 作者:行者123 更新时间:2023-11-29 04:22:14 25 4
gpt4 key购买 nike

我想将我的 customTableViewCell 的背景设置为黑色。经过一番搜索后,最常见的答案是在我的 CellForRowAtIndex 中执行此操作。

cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor blackColor];

但这并没有帮助。谁能帮帮我?

提前致谢!

最佳答案

按如下操作,并记住一件事,您在 contentview 上添加的任何 subview 都应该具有clearcolor。在我的例子中,我有默认的 textLabel,所以我将其设置为clear color。

 cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor blackColor];

关于objective-c - 设置自定义 tableviewCell 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12838870/

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