UITableViewCell Selected Background Color on Multiple Selection

后端 未结 14 1020
夕颜
夕颜 2020-12-08 04:26
// 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 cell         


        
14条回答
  •  爱一瞬间的悲伤
    2020-12-08 04:49

    Swift 3

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "yourCellIdentifier", for: indexPath)
        cell.selectionStyle = .none
        return cell
    }
    

    Swift 2

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
         let cell = tableView.dequeueReusableCell(withIdentifier: "yourCellIdentifier", for: indexPath)
         cell.selectionStyle = .None
         return cell
    }
    

提交回复
热议问题