kabochappinote

articlesswift
swift codeMemo (tableview,cell)

swift codeMemo (tableview,cell)


2021-08-31 11:08:21

⚪︎ cellの選択時背景色を消す

   
 let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", 
                                          for: indexPath)
 cell.selectionStyle = .none // 選択時の背景色無し
 return cell



⚪︎ tableView cell選択時背景色のアニメーション

   
// cell タップ時、選択色が徐々に消えていく
extension ViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, 
                     didSelectRowAt indexPath: IndexPath) {

        tableView.deselectRow(at: indexPath, animated: true)

    }
}

back