2016-04-15 100 views
0

UITableViewCell默认效果,当按下单元格时,单元格将变为灰色背景.UITableViewCell子视图控件也会更改背景颜色。 如何让孩子查看背景不变?UITableViewCell选定背景效果

+0

这个问题类似http://stackoverflow.com/questions/26895370/swift-uitableviewcell-selected-background-color-on-multiple-selection?rq = 1 – muneeb

+0

我看你提供的网站,效果不是我想要的。但是还是要感谢你。 – ChildrenGreens

回答

0

这可能是适合你:

[cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
+0

我需要的效果是:当一个单元格被按下时,背景颜色是灰色的。松开手指单元格恢复到原始效果。 – ChildrenGreens

0

使用此代码,

let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"cell") 

cell.selectionStyle = UITableViewCellSelectionStyle.None 
return cell 

希望它有帮助

+0

我需要的效果是:当一个单元格被按下时,背景颜色是灰色的。松开手指单元格回到原始效果 – ChildrenGreens

+0

您需要使用效果,** didSelectRowAtIndexPath:**方法 'tableView.deselectRowAtIndexPath(indexPath,动画:真)' –

+0

这样我知道,但子视图设置单元格的背景颜色,并提出了上述问题。 – ChildrenGreens