我想突出顯示我的tableView中的一些單元格。突出顯示我的意思是將單元格的背景顏色設置爲例如複製文本時使用的藍色。我用嘗試這種代碼,以檢查是否正常工作突出顯示一個tableViewCell
public func tableView(_ tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.setHighlighted(true, animated: false)
}
我也試過這個
cell.setSelected(true, animated: false)
在這兩種情況下,細胞變得灰色和藍色沒有。有沒有解決方案?
你試圖設置單元格的'selectionStyle'到'blue'? –