简体   繁体   English

如何在UItableViewCell中将附件视图背景设置为与内容视图相同的背景?

[英]How to set accessory view background to same background as content view in UItableViewCell?

I've successfully changed the background of table view cells to an image in my app but it does not extend to the background of the accessory view. 我已经成功地将表格视图单元格的背景更改为我的应用程序中的图像,但它没有扩展到附件视图的背景。 Any idea to fix this ? 有什么想法解决这个问题?

Thx for helping, 感谢帮助,

Stephane 斯特凡

cell.textLabel.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg-Cell-Image.jpg"]];

try this way if you are using text label of the cell only to display content 如果您只使用单元格的文本标签来显示内容,请尝试这种方式

You can use the tableView:willDisplayCell:forRowAtIndexPath: delegate function of tableview. 您可以使用tableView:willDisplayCell:forRowAtIndexPath: tableview的委托函数。 Give background color to the cell in that function. 为该函数中的单元格提供背景颜色。 It will give the color to accessary view background also. 它还将颜色赋予附加视图背景。

This is an old thread, that I found most helpful. 这是一个老线程,我觉得最有帮助。 What worked for me though, was to set the cell color in IB (the cell was a prototype): 对我来说有用的是在IB中设置单元格颜色(单元格是原型):

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM