【发布时间】:2015-01-09 19:13:15
【问题描述】:
// Doesn't work
cell.selectionStyle = .Blue
//Works when the selection is not multiple, if it's multiple with each selection the previous one disappear...
let cellBGView = UIView()
cellBGView.backgroundColor = UIColor(red: 0, green: 0, blue: 200, alpha: 0.4)
cell.selectedBackgroundView = cellBGView
任何答案如何设置被选中的单元格的背景颜色?
【问题讨论】:
-
将背景视图设置为蓝色对我来说效果很好;当我选择它时,每个单元格都保持蓝色。您确定您的表格视图设置为多选吗?
-
是的,选择是多个...当我点击单元格时,它会得到这个背景,但是当我点击另一个单元格时,它会改变颜色,但是,第一个点击的单元格的背景会恢复正常颜色.
-
cell.multipleSelectionBackgroundView = cellBGView //也不行...
-
那个.... 听起来好像没有打开多选。你确定你打开了
allowsMultipleSelection,而不是allowsMultipleSelectionDuringEditing? -
我点击第一个单元格得到这个背景,当我点击另一个再次变蓝的单元格时,第一个单元格使用默认背景,但仍然被选中?
标签: ios uitableview swift selection selected