LoginSignup
1
1

More than 3 years have passed since last update.

[Swift5] cellをtapしたときのhighlightを無効にする方法

Posted at

はじめに

tableView全てのcell, または,特定のcellをtapしたときのhighlightを無効にする方法をメモしました.

tableView全体のcellに適用する場合

tableView.allowsSelection = false

上記を記述することで,didSelectRowAt#が動作しなくなるので,tapしてもアニメーションが発生しなくなります.

ただし,cellの上にUIButtonを配置した場合,そのbuttonはdidSelectRowAt#と関係ないので動作します.

UITableViewが編集モードの時にも無効にしたい場合,上の記述に加えて以下を記述する.

tableView.allowsSelectionDuringEditing = false 

特定のcellに適用する場合

cell.selectionStyle = .none

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1