こちらの大変素晴らしい記事を参考にさせていただきました。
2015年のコードですが2021でも使えると思います。
extension UITableViewCell {
@IBInspectable
var selectedBackgroundColor: UIColor? {
get {
return selectedBackgroundView?.backgroundColor
}
set(color) {
let background = UIView()
background.backgroundColor = color
selectedBackgroundView = background
}
}
}
こうすることでセルを選択してもセルの背景の色が変わらなくなります。
Selectionの項目はDefaultでもOKです。
StoryBoard上から設定できるのでstaticTableViewでもうまくできましたし、
先頭にチェックマークをつけた状態でもこの方法であれば背景の色だけ無くなってくれます。
先頭チャックマークの出し方はこちらの記事を参考にすると良いです。
tableView.isEditing = true
tableView.allowsMultipleSelection = true
tableView.allowsMultipleSelectionDuringEditing = true
を追加するだけで良いそうです。