[英]How can i change the background color of a table cell with multiple sections?
I have a table view with multiple sections and don't know how to change the background color when i touch that row.我有一个包含多个部分的表格视图,当我触摸该行时不知道如何更改背景颜色。
I've found this link about table cells but it is addressed to tables with only one section:我找到了这个关于表格单元格的链接,但它只针对只有一个部分的表格:
changing cell background on click on cell in iphone . 在 iphone 中单击单元格时更改单元格背景。
cell.selectedBackgroundView = [[ UIView alloc] init];
[cell.selectedBackgroundView setBackgroundColor:[UIColor purpleColor]];
if i use the code from this link, cells that are rounded (the first and last in every section) will have a rectangle on finger over which doesn't look good.如果我使用此链接中的代码,则被舍入的单元格(每个部分中的第一个和最后一个)将在手指上有一个看起来不太好的矩形。
How can i make this rectangle curved around the edges for the first and last row in every section?我怎样才能使这个矩形围绕每个部分的第一行和最后一行的边缘弯曲?
How about using some quartz core.使用一些石英芯怎么样。 you can make any view round rect using
view.layer.cornerRadius = 5.0;
您可以使用
view.layer.cornerRadius = 5.0;
make sure to import header确保导入 header
#import <QuartzCore/QuartzCore.h>
EDIT编辑
Try to create custom cell then and set a UIView for background view property and change color as you wish.然后尝试创建自定义单元格并为背景视图属性设置 UIView 并根据需要更改颜色。 That way it will work.
这样它就会起作用。
UPDATE更新
Yes you are right.是的你是对的。 There is tutorial on internet for grouped tableView's let me google it for you.
互联网上有分组 tableView 的教程,让我为您搜索它。 Use this post it has everything you need http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/
使用这篇文章它有你需要的一切http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/
here is another stackoverflow post for the same这是另一个相同的stackoverflow帖子
How to customize the background/border colors of a grouped table view cell? 如何自定义分组表格视图单元格的背景/边框 colors?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.