Swift:UITableViewCell 在选中时突出显示整个单元格而不是仅图像视图
Swift: TableViewCell hightlights the whole cell when selected instead only the image view
我的设置如下所示:Screenshot
如您所见,我使用 TableViewsCells,然后将 ImageViews 放在单元格中。但是正如您在屏幕截图上看到的那样,每当我将手指放在 tableview 上时,它都会突出显示整个单元格区域而不是作为背景的 ImageView,那么我如何才能确保它只突出显示背景图像?谢谢
您可以在 UITableViewCell
中将 selectionStyle
设置为 .none
,然后覆盖 isSelected
。
override var isSelected: Bool {
didSet {
// do whatever you want to your image here
}
}
我的设置如下所示:Screenshot
如您所见,我使用 TableViewsCells,然后将 ImageViews 放在单元格中。但是正如您在屏幕截图上看到的那样,每当我将手指放在 tableview 上时,它都会突出显示整个单元格区域而不是作为背景的 ImageView,那么我如何才能确保它只突出显示背景图像?谢谢
您可以在 UITableViewCell
中将 selectionStyle
设置为 .none
,然后覆盖 isSelected
。
override var isSelected: Bool {
didSet {
// do whatever you want to your image here
}
}