UISearchController 搜索结果单元格背景色
UISearchController search result cell background color
我的 UISearchController
在 UITableViewCell
秒内显示搜索结果,背景颜色我没有设置
我通过调试视图可以看出这个灰色是cell.contentView
的灰色。但是,它对我的设置没有反应
cell.contentView.backgroundColor = [UIColor whiteColor];
在 tableView:cellForRowAtIndexPath:
方法中。
还有其他方法可以覆盖那种奇怪的灰色吗?
您能否提供一个重现您的场景的示例项目? tableView:cellForRowAtIndexPath:
是什么样子的?如果是这样,我们可能会更有帮助地确定问题。
在不知道具体细节的情况下,可能值得尝试在 tableView:willDisplayCell:forRowAtIndexPath:
中设置 contentView 的背景颜色,这比 tableView:cellForRowAtIndexPath:
晚一点
创建自己的 UITableViewCell
子类可能也值得,这样您就可以更好地控制单元格的着色。
我的 UISearchController
在 UITableViewCell
秒内显示搜索结果,背景颜色我没有设置
我通过调试视图可以看出这个灰色是cell.contentView
的灰色。但是,它对我的设置没有反应
cell.contentView.backgroundColor = [UIColor whiteColor];
在 tableView:cellForRowAtIndexPath:
方法中。
还有其他方法可以覆盖那种奇怪的灰色吗?
您能否提供一个重现您的场景的示例项目? tableView:cellForRowAtIndexPath:
是什么样子的?如果是这样,我们可能会更有帮助地确定问题。
在不知道具体细节的情况下,可能值得尝试在 tableView:willDisplayCell:forRowAtIndexPath:
中设置 contentView 的背景颜色,这比 tableView:cellForRowAtIndexPath:
创建自己的 UITableViewCell
子类可能也值得,这样您就可以更好地控制单元格的着色。